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

Commit

Permalink
Merge remote-tracking branch 'origin/master' into go-1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Sep 30, 2019
2 parents cd3edca + d49eb00 commit 6ab0015
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Configuration workflow `ship.yaml` files can be included in Kubernetes manifest
Ship is packaged as a single binary, and Linux and MacOS versions are distributed:
- To download the latest Linux build, run:
```shell
curl -sSL https://github.com/replicatedhq/ship/releases/download/v0.47.2/ship_0.47.2_linux_amd64.tar.gz | tar zxv && sudo mv ship /usr/local/bin
curl -sSL https://github.com/replicatedhq/ship/releases/download/v0.51.2/ship_0.51.2_linux_amd64.tar.gz | tar zxv && sudo mv ship /usr/local/bin
```

- To download the latest MacOS build, you can either run:
```shell
curl -sSL https://github.com/replicatedhq/ship/releases/download/v0.47.2/ship_0.47.2_darwin_amd64.tar.gz | tar zxv && sudo mv ship /usr/local/bin
curl -sSL https://github.com/replicatedhq/ship/releases/download/v0.51.2/ship_0.51.2_darwin_amd64.tar.gz | tar zxv && sudo mv ship /usr/local/bin
```

- ... or you can install with [Homebrew](https://brew.sh/):
Expand Down
32 changes: 27 additions & 5 deletions pkg/templates/installation_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ func (ctx *InstallationContext) entitlementValue(name string) string {
}

func (ctx *InstallationContext) shipCustomerRelease() string {
restrictedMeta := ctx.Meta
restrictedMeta.ConfigSpec = ""
restrictedMeta.CollectSpec = ""
restrictedMeta.AnalyzeSpec = ""
restrictedMeta.GithubContents = nil
restrictedMeta.Images = nil

data, err := util.MarshalIndent(2, restrictedMeta)
if err != nil {
level.Error(ctx.Logger).Log("msg", "unable to marshal release meta", "err", err)
return ""
}
return string(data)
}

func (ctx *InstallationContext) shipCustomerReleaseFull() string {
data, err := util.MarshalIndent(2, ctx.Meta)
if err != nil {
level.Error(ctx.Logger).Log("msg", "unable to marshal release meta", "err", err)
Expand All @@ -43,6 +59,10 @@ func (ctx *InstallationContext) shipCustomerRelease() string {
return string(data)
}

func (ctx *InstallationContext) configSpec() string {
return ctx.Meta.ConfigSpec
}

func (ctx *InstallationContext) collectSpec() string {
return ctx.Meta.CollectSpec
}
Expand All @@ -53,11 +73,13 @@ func (ctx *InstallationContext) analyzeSpec() string {

func (ctx *InstallationContext) FuncMap() template.FuncMap {
return template.FuncMap{
"ShipCustomerRelease": ctx.shipCustomerRelease,
"EntitlementValue": ctx.entitlementValue,
"LicenseFieldValue": ctx.entitlementValue,
"CollectSpec": ctx.collectSpec,
"AnalyzeSpec": ctx.analyzeSpec,
"ShipCustomerRelease": ctx.shipCustomerRelease,
"ShipCustomerReleaseFull": ctx.shipCustomerReleaseFull,
"EntitlementValue": ctx.entitlementValue,
"LicenseFieldValue": ctx.entitlementValue,
"ConfigSpec": ctx.configSpec,
"CollectSpec": ctx.collectSpec,
"AnalyzeSpec": ctx.analyzeSpec,
"Installation": func(name string) string {
switch name {
case "state_file_path":
Expand Down
159 changes: 159 additions & 0 deletions pkg/templates/installation_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,165 @@ func testCases() []TestInstallation {
v1:
- {}`,
},
{
Name: "ship customer release",
Meta: api.ReleaseMetadata{
AnalyzeSpec: `this is not an analyze spec`,
ConfigSpec: ``,
CollectSpec: ``,
GithubContents: []api.GithubContent{{
Repo: "abc",
Path: "xyz",
Ref: "test",
Files: []api.GithubFile{{
Name: "abc",
Path: "xyz",
Sha: "123",
Size: 456,
Data: "789",
}},
}},
Images: []api.Image{{
URL: "abc",
Source: "xyz",
AppSlug: "123",
ImageKey: "456",
}},
LicenseID: "myLicenseID",
},
Tpl: `{{repl ShipCustomerRelease }}`,
Expected: `releaseId: ""
sequence: 0
customerId: ""
installation: ""
channelId: ""
appSlug: ""
licenseId: myLicenseID
channelName: ""
channelIcon: ""
semver: ""
releaseNotes: ""
created: ""
installed: ""
registrySecret: ""
images: []
githubContents: []
shipAppMetadata:
description: ""
version: ""
icon: ""
name: ""
readme: ""
url: ""
contentSHA: ""
releaseNotes: ""
entitlements:
meta:
lastupdated: 0001-01-01T00:00:00Z
customerid: ""
serialized: ""
signature: ""
values: []
utilizations: []
entitlementSpec: ""
configSpec: ""
collectSpec: ""
analyzeSpec: ""
type: ""
license:
id: ""
assignee: ""
createdAt: 0001-01-01T00:00:00Z
expiresAt: 0001-01-01T00:00:00Z
type: ""
`,
},
{
Name: "ship customer release full",
Meta: api.ReleaseMetadata{
AnalyzeSpec: `this is not an analyze spec`,
ConfigSpec: `this is not a config spec`,
CollectSpec: `this is not a collect spec`,
GithubContents: []api.GithubContent{{
Repo: "abc",
Path: "xyz",
Ref: "test",
Files: []api.GithubFile{{
Name: "abc",
Path: "xyz",
Sha: "123",
Size: 456,
Data: "789",
}},
}},
Images: []api.Image{{
URL: "abc",
Source: "xyz",
AppSlug: "123",
ImageKey: "456",
}},
LicenseID: "myLicenseID",
},
Tpl: `{{repl ShipCustomerReleaseFull }}`,
Expected: `releaseId: ""
sequence: 0
customerId: ""
installation: ""
channelId: ""
appSlug: ""
licenseId: myLicenseID
channelName: ""
channelIcon: ""
semver: ""
releaseNotes: ""
created: ""
installed: ""
registrySecret: ""
images:
- url: abc
source: xyz
appSlug: "123"
imageKey: "456"
githubContents:
- repo: abc
path: xyz
ref: test
files:
- name: abc
path: xyz
sha: "123"
size: 456
data: "789"
shipAppMetadata:
description: ""
version: ""
icon: ""
name: ""
readme: ""
url: ""
contentSHA: ""
releaseNotes: ""
entitlements:
meta:
lastupdated: 0001-01-01T00:00:00Z
customerid: ""
serialized: ""
signature: ""
values: []
utilizations: []
entitlementSpec: ""
configSpec: this is not a config spec
collectSpec: this is not a collect spec
analyzeSpec: this is not an analyze spec
type: ""
license:
id: ""
assignee: ""
createdAt: 0001-01-01T00:00:00Z
expiresAt: 0001-01-01T00:00:00Z
type: ""
`,
},
}
return tests
}
2 changes: 1 addition & 1 deletion web/init/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replicatedhq/ship-init",
"version": "1.6.7",
"version": "1.6.9",
"description": "Shared component that contains the Ship Init app",
"author": "Replicated, Inc.",
"license": "Apache-2.0",
Expand Down
9 changes: 5 additions & 4 deletions web/init/src/ShipConfigRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import "./scss/index.scss";

export class ShipConfigRenderer extends React.Component {
static propTypes = {
/** Config groups itesms to render */
groups: PropTypes.array.isRequired,
groups: PropTypes.array.isRequired, // Config groups items to render
handleChange: PropTypes.func,
getData: PropTypes.func,
}

static defaultProps = {
Expand All @@ -32,8 +33,8 @@ export class ShipConfigRenderer extends React.Component {
<ConfigRender
fieldsList={groupsList}
fields={_groups}
handleChange={() => { return; }}
getData={() => { return; }}
handleChange={this.props.handleChange || (() => { return; })}
getData={this.props.getData || (() => { return; })}
/>
</div>
)
Expand Down

0 comments on commit 6ab0015

Please sign in to comment.