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

Commit 96a0fc2

Browse files
authored
Merge pull request #638 from laverya/change-state.json-metadata-to-struct
ship metadata should be a struct not a map[string]string
2 parents c38a4f7 + 2c946a7 commit 96a0fc2

File tree

11 files changed

+29
-31
lines changed

11 files changed

+29
-31
lines changed

integration/base/conditional-asset/expected/.ship/state.json

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
"contentSHA": "e935ace16aacb22dc0fc5eccb3e7cc44c25ae8ffeca805c434317449d595800a",
77
"metadata": {
88
"applicationType": "replicated.app",
9-
"customerID": "",
10-
"installationID": "",
119
"releaseNotes": "",
1210
"version": ""
1311
}

integration/base/docker-push/expected/.ship/state.json

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"contentSHA": "f1a562de29d7dbb760c9d20382613a47bff882ecf71f21ad5f1c67bbffa9fedd",
88
"metadata": {
99
"applicationType": "replicated.app",
10-
"customerID": "",
11-
"installationID": "",
1210
"releaseNotes": "",
1311
"version": ""
1412
}

integration/base/helm-fetch/expected/.ship/state.json

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"contentSHA": "54e761100cb39926d58cb68ddc20437347240310f5cbdce01f00d7e085d4c2b1",
55
"metadata": {
66
"applicationType": "replicated.app",
7-
"customerID": "",
8-
"installationID": "",
97
"releaseNotes": "",
108
"version": ""
119
}

integration/base/render-root/expected/.ship/state.json

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"contentSHA": "43908c014adbcd9b9c7bd5eb548fc5086c7a9f85b009c70a16e2902097d73784",
55
"metadata": {
66
"applicationType": "replicated.app",
7-
"customerID": "",
8-
"installationID": "",
97
"releaseNotes": "",
108
"version": ""
119
}

integration/init/git-root-directory/expected/.ship/state.json

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"upstream": "https://github.com/replicatedhq/test-chart-root-dir/tree/507feecae588c958ebe82bcf701b8be63f34ac9b/",
77
"metadata": {
88
"applicationType": "helm",
9-
"icon": "",
109
"name": "values-update",
1110
"releaseNotes": "test chart",
1211
"version": "0.1.0"

integration/update/basic/expected/.ship/state.json

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
},
1515
"metadata": {
1616
"applicationType": "helm",
17-
"icon": "",
1817
"name": "basic",
1918
"releaseNotes": "Update README.md",
2019
"version": "0.1.0"

integration/update/modify-chart/expected/.ship/state.json

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
},
1515
"metadata": {
1616
"applicationType": "helm",
17-
"icon": "",
1817
"name": "modify-chart",
1918
"releaseNotes": "Update values.yaml",
2019
"version": "0.1.0"

integration/update/values-static/expected/.ship/state.json

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
},
1515
"metadata": {
1616
"applicationType": "helm",
17-
"icon": "",
1817
"name": "values-update",
1918
"releaseNotes": "add static chart (will not be updated)",
2019
"version": "0.1.0"

pkg/state/manager.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ func (m *MManager) SerializeShipMetadata(metadata api.ShipAppMetadata, applicati
7777
}
7878

7979
versionedState := current.Versioned()
80-
versionedState.V1.Metadata = map[string]string{
81-
"applicationType": applicationType,
82-
"releaseNotes": metadata.ReleaseNotes,
83-
"version": metadata.Version,
84-
"icon": metadata.Icon,
85-
"name": metadata.Name,
80+
versionedState.V1.Metadata = &Metadata{
81+
ApplicationType: applicationType,
82+
ReleaseNotes: metadata.ReleaseNotes,
83+
Version: metadata.Version,
84+
Icon: metadata.Icon,
85+
Name: metadata.Name,
8686
}
8787

8888
return m.serializeAndWriteState(versionedState)
@@ -99,12 +99,12 @@ func (m *MManager) SerializeAppMetadata(metadata api.ReleaseMetadata) error {
9999
}
100100

101101
versionedState := current.Versioned()
102-
versionedState.V1.Metadata = map[string]string{
103-
"applicationType": "replicated.app",
104-
"releaseNotes": metadata.ReleaseNotes,
105-
"customerID": metadata.CustomerID,
106-
"installationID": metadata.InstallationID,
107-
"version": metadata.Semver,
102+
versionedState.V1.Metadata = &Metadata{
103+
ApplicationType: "replicated.app",
104+
ReleaseNotes: metadata.ReleaseNotes,
105+
Version: metadata.Semver,
106+
CustomerID: metadata.CustomerID,
107+
InstallationID: metadata.InstallationID,
108108
}
109109

110110
return m.serializeAndWriteState(versionedState)

pkg/state/manager_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,12 @@ func TestMManager_SerializeShipMetadata(t *testing.T) {
429429
},
430430
expected: VersionedState{
431431
V1: &V1{
432-
Metadata: map[string]string{
433-
"applicationType": "mock application type",
434-
"releaseNotes": "",
435-
"version": "test version",
436-
"icon": "test icon",
437-
"name": "test name",
432+
Metadata: &Metadata{
433+
ApplicationType: "mock application type",
434+
ReleaseNotes: "",
435+
Version: "test version",
436+
Icon: "test icon",
437+
Name: "test name",
438438
},
439439
},
440440
},

pkg/state/models.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type V1 struct {
6060
HelmValuesDefaults string `json:"helmValuesDefaults,omitempty" yaml:"helmValuesDefaults,omitempty" hcl:"helmValuesDefaults,omitempty"`
6161
Kustomize *Kustomize `json:"kustomize,omitempty" yaml:"kustomize,omitempty" hcl:"kustomize,omitempty"`
6262
Upstream string `json:"upstream,omitempty" yaml:"upstream,omitempty" hcl:"upstream,omitempty"`
63-
Metadata map[string]string `json:"metadata" yaml:"metadata" hcl:"metadata"`
63+
Metadata *Metadata `json:"metadata" yaml:"metadata" hcl:"metadata"`
6464
//deprecated in favor of upstream
6565
ChartURL string `json:"chartURL,omitempty" yaml:"chartURL,omitempty" hcl:"chartURL,omitempty"`
6666
ChartRepoURL string `json:"ChartRepoURL,omitempty" yaml:"ChartRepoURL,omitempty" hcl:"ChartRepoURL,omitempty"`
@@ -69,6 +69,16 @@ type V1 struct {
6969
Lifecycle *Lifeycle `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty" hcl:"lifecycle,omitempty"`
7070
}
7171

72+
type Metadata struct {
73+
ApplicationType string `json:"applicationType" yaml:"applicationType" hcl:"applicationType"`
74+
Icon string `json:"icon,omitempty" yaml:"icon,omitempty" hcl:"icon,omitempty"`
75+
Name string `json:"name,omitempty" yaml:"name,omitempty" hcl:"name,omitempty"`
76+
ReleaseNotes string `json:"releaseNotes" yaml:"releaseNotes" hcl:"releaseNotes"`
77+
Version string `json:"version" yaml:"version" hcl:"version"`
78+
CustomerID string `json:"customerID,omitempty" yaml:"customerID,omitempty" hcl:"customerID,omitempty"`
79+
InstallationID string `json:"installationID,omitempty" yaml:"installationID,omitempty" hcl:"installationID,omitempty"`
80+
}
81+
7282
type StepsCompleted map[string]interface{}
7383

7484
func (s StepsCompleted) String() string {

0 commit comments

Comments
 (0)