Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #855 from dexhorthy/specific-render
Browse files Browse the repository at this point in the history
Add ability for render steps to specify specific assets
  • Loading branch information
dexhorthy authored Mar 11, 2019
2 parents f449726 + a215b1e commit 268ee8c
Show file tree
Hide file tree
Showing 37 changed files with 860 additions and 79 deletions.
12 changes: 10 additions & 2 deletions hack/docs/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1107,9 +1107,17 @@
{
"path": "properties.lifecycle.properties.v1.items.properties.render",
"merge": {
"description": "A `render` step will do the work of collecting configuration values from a user and using them to generate the final assets that can be used to deploy an application.",
"description": "A `render` step will do the work of collecting configuration values from a user and using them to generate the final assets that can be used to deploy an application. If an `assets` field is set, those assets will be rendered rather than the top-level `assets` object",
"examples": [
{}
{},
{ "root": "./"},
{
"root": "./",
"assets": {
"v1": [{
"inline": { "contents": "some-asset", "dest": "some-path.txt"}
}
]}}
]
},
"replace": {
Expand Down
608 changes: 606 additions & 2 deletions hack/docs/schema.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
assets:
v1:
- inline:
dest: ./install.sh
contents: |
#!/bin/sh
echo installing...
config: {}
lifecycle:
v1:
- render:
root: do
- render:
root: undo
assets:
v1:
- inline:
dest: ./uninstall.sh
contents: |
#!/bin/sh
echo uninstalling...
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"v1": {
"config": {},
"contentSHA": "8ce189bc6b0c8992933394cc4a15b17aa51e6a3bc70e2238785ae84581c86699",
"metadata": {
"applicationType": "replicated.app",
"releaseNotes": "",
"version": ""
},
"releaseName": "ship",
"upstream": "__upstream__"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo installing...
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo uninstalling...
23 changes: 23 additions & 0 deletions integration/base/direct-render-with-root-2/input/.ship/ship.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
assets:
v1:
- inline:
dest: ./install.sh
contents: |
#!/bin/sh
echo installing...
config: {}
lifecycle:
v1:
- render:
root: do
- render:
root: undo
assets:
v1:
- inline:
dest: ./uninstall.sh
contents: |
#!/bin/sh
echo uninstalling...
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
2 changes: 2 additions & 0 deletions integration/base/direct-render-with-root-2/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_cleanup: false
disable_online: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
assets:
v1:
- inline:
dest: ./install.sh
contents: |
#!/bin/sh
echo installing...
config: {}
lifecycle:
v1:
- render: {}
- render:
root: ./
assets:
v1:
- inline:
dest: ./uninstall.sh
contents: |
#!/bin/sh
echo uninstalling...
13 changes: 13 additions & 0 deletions integration/base/direct-render-with-root/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"v1": {
"config": {},
"contentSHA": "3a28dfd4ef900b7fc0ba9ce90626d3acc8b52d25afb6cf3a9464788343feb0c7",
"metadata": {
"applicationType": "replicated.app",
"releaseNotes": "",
"version": ""
},
"releaseName": "ship",
"upstream": "__upstream__"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo installing...
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo uninstalling...
22 changes: 22 additions & 0 deletions integration/base/direct-render-with-root/input/.ship/ship.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
assets:
v1:
- inline:
dest: ./install.sh
contents: |
#!/bin/sh
echo installing...
config: {}
lifecycle:
v1:
- render: {}
- render:
root: ./
assets:
v1:
- inline:
dest: ./uninstall.sh
contents: |
#!/bin/sh
echo uninstalling...
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
2 changes: 2 additions & 0 deletions integration/base/direct-render-with-root/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_cleanup: false
disable_online: true
23 changes: 23 additions & 0 deletions integration/base/direct-render/expected/.ship/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
assets:
v1:
- inline:
dest: ./install.sh
contents: |
#!/bin/sh
echo installing...
config: {}
lifecycle:
v1:
- render:
root: ./
- render:
root: ./
assets:
v1:
- inline:
dest: ./uninstall.sh
contents: |
#!/bin/sh
echo uninstalling...
13 changes: 13 additions & 0 deletions integration/base/direct-render/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"v1": {
"config": {},
"contentSHA": "d04ecc9031dc7f8670e54f5881c77fa3623910abdca3d54344939e6e3d4a3167",
"metadata": {
"applicationType": "replicated.app",
"releaseNotes": "",
"version": ""
},
"releaseName": "ship",
"upstream": "__upstream__"
}
}
2 changes: 2 additions & 0 deletions integration/base/direct-render/expected/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo installing...
2 changes: 2 additions & 0 deletions integration/base/direct-render/expected/uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo uninstalling...
23 changes: 23 additions & 0 deletions integration/base/direct-render/input/.ship/ship.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
assets:
v1:
- inline:
dest: ./install.sh
contents: |
#!/bin/sh
echo installing...
config: {}
lifecycle:
v1:
- render:
root: ./
- render:
root: ./
assets:
v1:
- inline:
dest: ./uninstall.sh
contents: |
#!/bin/sh
echo uninstalling...
2 changes: 2 additions & 0 deletions integration/base/direct-render/input/.ship/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
2 changes: 2 additions & 0 deletions integration/base/direct-render/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_cleanup: false
disable_online: true
41 changes: 1 addition & 40 deletions integration/init_app/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io/ioutil"
"net/url"
"os"
"path"
"strings"
Expand All @@ -17,11 +16,7 @@ import (
"github.com/onsi/gomega/format"
"github.com/replicatedhq/ship/integration"
"github.com/replicatedhq/ship/pkg/cli"
"github.com/replicatedhq/ship/pkg/e2e"
"github.com/replicatedhq/ship/pkg/logger"
"github.com/spf13/afero"
"github.com/spf13/viper"
yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"
)

type TestMetadata struct {
Expand Down Expand Up @@ -158,40 +153,6 @@ var _ = Describe("ship init replicated.app/...", func() {
}
})

func createRelease(
vendorEndpoint string,
vendorToken string,
testInputPath string,
testMetadata TestMetadata,
channelName string,
customerID string,
) string {
endpointURL, err := url.Parse(vendorEndpoint)
Expect(err).NotTo(HaveOccurred())
vendorClient := &e2e.GraphQLClient{
GQLServer: endpointURL,
Token: vendorToken,
Logger: logger.New(
viper.GetViper(),
afero.Afero{Fs: afero.NewMemMapFs()},
),
}
releaseContents, err := ioutil.ReadFile(path.Join(testInputPath, ".ship/release.yml"))
Expect(err).NotTo(HaveOccurred())
channel, err := vendorClient.GetOrCreateChannel(channelName)
Expect(err).NotTo(HaveOccurred())
_, err = vendorClient.PromoteRelease(
string(releaseContents),
channel.ID,
testMetadata.ReleaseVersion,
"integration tests",
)
Expect(err).NotTo(HaveOccurred())
installationID, err := vendorClient.EnsureCustomerOnChannel(customerID, channel.ID)
Expect(err).NotTo(HaveOccurred())
return installationID
}

func readMetadata(testPath string) TestMetadata {
var testMetadata TestMetadata
metadataBytes, err := ioutil.ReadFile(path.Join(testPath, "metadata.yaml"))
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func (m *Message) ShortName() string { return "message" }
// Render is a lifeycle step to collect config and render assets
type Render struct {
StepShared `json:",inline" yaml:",inline" hcl:",inline"`
Root string `json:"root,omitempty" yaml:"root,omitempty" hcl:"root,omitempty"`
Root string `json:"root,omitempty" yaml:"root,omitempty" hcl:"root,omitempty"`
Assets *Assets `json:"assets,omitempty" yaml:"assets,omitempty" hcl:"assets,omitempty"`
}

func (r *Render) Shared() *StepShared { return &r.StepShared }
Expand Down
27 changes: 27 additions & 0 deletions pkg/api/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,33 @@ lifecycle:
Render: &Render{},
},
},
{
name: "render with override assets",
yaml: `
---
lifecycle:
v1:
- render:
root: ./bigapp
assets:
v1:
- inline: { contents: fake }`,

expect: Step{
Render: &Render{
Root: "./bigapp",
Assets: &Assets{
V1: []Asset{
{
Inline: &InlineAsset{
Contents: "fake",
},
},
},
},
},
},
},
{
name: "terraform",
yaml: `
Expand Down
1 change: 0 additions & 1 deletion pkg/lifecycle/kustomize/kustomizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/replicatedhq/ship/pkg/lifecycle/daemon/daemontypes"
"github.com/replicatedhq/ship/pkg/state"
"github.com/replicatedhq/ship/pkg/util"

"github.com/spf13/afero"
yaml "gopkg.in/yaml.v2"
"sigs.k8s.io/kustomize/pkg/patch"
Expand Down
1 change: 0 additions & 1 deletion pkg/lifecycle/render/docker/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/replicatedhq/ship/pkg/lifecycle/render/root"
"github.com/replicatedhq/ship/pkg/templates"
"github.com/replicatedhq/ship/pkg/util"

"github.com/spf13/viper"
)

Expand Down
1 change: 0 additions & 1 deletion pkg/lifecycle/render/dockerlayer/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/replicatedhq/ship/pkg/lifecycle/render/docker"
"github.com/replicatedhq/ship/pkg/lifecycle/render/root"
"github.com/replicatedhq/ship/pkg/util"

"github.com/spf13/afero"
"github.com/spf13/viper"
)
Expand Down
1 change: 0 additions & 1 deletion pkg/lifecycle/render/github/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/replicatedhq/ship/pkg/state"
"github.com/replicatedhq/ship/pkg/templates"
"github.com/replicatedhq/ship/pkg/util"

"github.com/spf13/afero"
"github.com/spf13/viper"
)
Expand Down
1 change: 0 additions & 1 deletion pkg/lifecycle/render/inline/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/replicatedhq/ship/pkg/lifecycle/render/root"
"github.com/replicatedhq/ship/pkg/templates"
"github.com/replicatedhq/ship/pkg/util"

"github.com/spf13/viper"
)

Expand Down
1 change: 0 additions & 1 deletion pkg/lifecycle/render/local/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/replicatedhq/libyaml"
"github.com/replicatedhq/ship/pkg/api"
"github.com/replicatedhq/ship/pkg/util"

"github.com/spf13/afero"
)

Expand Down
Loading

0 comments on commit 268ee8c

Please sign in to comment.