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

Commit 34d01be

Browse files
authored
Merge pull request #995 from laverya/include-all-release-info-in-content-sha
include all release info for replicated.app upstreams in the content sha
2 parents 8c70e06 + 7d90a32 commit 34d01be

File tree

27 files changed

+44
-30
lines changed

27 files changed

+44
-30
lines changed

integration/base/amazon-eks/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"v1": {
33
"config": {},
4-
"contentSHA": "0f476537db7bf02980df88c12f4b43c87094314635477263a2a5468f3c74a2dc",
4+
"contentSHA": "7c1c9d536fd96ffe4f5de5a75014bac39c6c36d618813d9f14f539805c726352",
55
"metadata": {
66
"applicationType": "replicated.app",
77
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

integration/base/basic-stateless/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"v1": {
33
"config": {},
4-
"contentSHA": "af39a2dca324dad4488ac70eaca71806bf2def699bed604c1252b6333588309d",
4+
"contentSHA": "49e1c9f9fa33aaa5bfe04f7c1add52397f649b8d96842b8834a939db883438ca",
55
"metadata": {
66
"applicationType": "replicated.app",
77
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"config": {
44
"test_option": "abc123_test-option-value"
55
},
6-
"contentSHA": "af39a2dca324dad4488ac70eaca71806bf2def699bed604c1252b6333588309d",
6+
"contentSHA": "49e1c9f9fa33aaa5bfe04f7c1add52397f649b8d96842b8834a939db883438ca",
77
"metadata": {
88
"applicationType": "replicated.app",
99
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

integration/base/config-chain-override/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"t2_option": "abc123_abc123",
66
"t3_option": "abc123_abc123 + abc123"
77
},
8-
"contentSHA": "f256226c1517134c10dff4ba08dc3a6c55b28320f7ba0829b62c96ad84fe7106",
8+
"contentSHA": "a24b2f2247cdd061c97f64753deea506f57df4c950043630a27eedd7b8a29770",
99
"metadata": {
1010
"applicationType": "replicated.app",
1111
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

integration/base/config-chain/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"t2_option": "abc123_abc123",
66
"t3_option": "abc123_abc123 + abc123"
77
},
8-
"contentSHA": "f256226c1517134c10dff4ba08dc3a6c55b28320f7ba0829b62c96ad84fe7106",
8+
"contentSHA": "a24b2f2247cdd061c97f64753deea506f57df4c950043630a27eedd7b8a29770",
99
"metadata": {
1010
"applicationType": "replicated.app",
1111
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

integration/base/default-values/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"namespace": "Alpha",
77
"scheduler": ""
88
},
9-
"contentSHA": "377deb7eccf40c1fede60b7db73c69ba57f28eed0cfe0fdbb8cbe11ced3f64e4",
9+
"contentSHA": "d182801c311b0c937b7027f9b6a71704973e6bf97f9f466473aeaca804edd010",
1010
"metadata": {
1111
"applicationType": "replicated.app",
1212
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"config": {
44
"option": "value"
55
},
6-
"contentSHA": "181da1498e9c63c2b9a8b47446cce7dffd11c28b095814c7136a02391edbca8b",
6+
"contentSHA": "199522eb20f835e7060c9c20409daf18dc8169f118f6738bee4ae05ee1b4cde2",
77
"metadata": {
88
"applicationType": "replicated.app",
99
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"config": {
44
"test_option": "abc123_test-option-value"
55
},
6-
"contentSHA": "104541e8f52c5077198f4bd2f8a5021ee1a85c0e54d6058b3a757490add42f13",
6+
"contentSHA": "2838f12b0f9649afa3f10d5047e32fd532c7d2b15ae4ec2543b756bd2eb13b3f",
77
"metadata": {
88
"applicationType": "replicated.app",
99
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"v1": {
33
"config": {},
4-
"contentSHA": "b93b0ea7be591d5d017fe977093eab71958b9e89a062062e500961011fce7f39",
4+
"contentSHA": "d0a5407090d68a8cfbd220f94e2ea5c9f64ee5133d5c6016777854821c47f4b4",
55
"metadata": {
66
"applicationType": "replicated.app",
77
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

integration/base/integration_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ var _ = Describe("ship app", func() {
114114
Expect(err).NotTo(HaveOccurred())
115115

116116
ignoreUpstreamContents := map[string][]string{
117-
".ship/state.json": {"v1.upstreamContents", "v1.shipVersion"},
117+
".ship/state.json": {"v1.upstreamContents", "v1.shipVersion", "v1.contentSHA"},
118118
}
119119

120120
//compare the files in the temporary directory with those in the "expected" directory

integration/base/web/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"methodType": "GET",
55
"resourceURL": "https://raw.githubusercontent.com/replicatedhq/test-charts/5bf016aac1786cb74c678c3419bb8623f0388f8d/web-asset/web-asset"
66
},
7-
"contentSHA": "e2caa313a59af409fa4e096faa605ade4b5d506447ba3d4b90f25bea9d2ddffb",
7+
"contentSHA": "cd26c8e85fda23582ba8a3a067d1c7f76dfa421422d8a742064d6467ad6dda38",
88
"metadata": {
99
"applicationType": "replicated.app",
1010
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

integration/init_app/amazon-eks-template/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"v1": {
33
"config": {},
44
"upstream": "__upstream__",
5-
"contentSHA": "f1eaaa149478c1f7d4a4d42f603933b3b78d8a3df50cabf8ae209cbe990590de",
5+
"contentSHA": "242b9d4a6c479e4c864f24d8e9bc0420e471c9e48fed0b89eec0260f3fbc7f0e",
66
"metadata": {
77
"applicationType": "replicated.app",
88
"customerID": "__customerID__",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"v1": {
33
"config": {},
44
"upstream": "__upstream__",
5-
"contentSHA": "6faeec976f37e880c5e70cf578412a57fbfda3b35bf8e6f73221fe5fe88f1058",
5+
"contentSHA": "9728a969294231e722662390ed73a8573a1af59f7a50bce21a8373612b69635e",
66
"metadata": {
77
"applicationType": "replicated.app",
88
"customerID": "__customerID__",

integration/init_app/docker-asset-slug/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"sequence": 0,
1919
"version": "0.0.1"
2020
},
21-
"contentSHA": "4e212691de81e471f76ea6ef8d236bae3874d0bc2f22487d17e3e4e42138a67f",
21+
"contentSHA": "7694cf3b21c6fa8eb6ed0c92d9452096ddcd7e457fb2d728e5636eff2f5d2e10",
2222
"upstreamContents": {
2323
"appRelease": {
2424
"id": "oVSYJqtZnSew_8A3fFuwz0WPwn40zjn6",

integration/init_app/docker-asset/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"sequence": 0,
1919
"version": "1.0.0-SNAPSHOT"
2020
},
21-
"contentSHA": "a551e7640f88bd4d9e5843ea7602c046a1b89feae744c521bee558f9e44f0a69",
21+
"contentSHA": "55882cb70d6c27e8290668d1930b2a062570ac0fa8c459be94b6921c9ce7976f",
2222
"upstreamContents": {
2323
"appRelease": {
2424
"id": "jDtI-DiraCbkN5euJHmbS3kIFw4N1Iw9",

integration/init_app/github-template-func/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"option": "abc123"
55
},
66
"upstream": "__upstream__",
7-
"contentSHA": "9fb30c009a2bb7202d3b0dfe7683823f799e238fd6132316de1cdbc54062dc6f",
7+
"contentSHA": "6327e26ed6f0c8c7f693b3343d51f013048e4b5a87cf24f004e81dc7a8d8fd69",
88
"metadata": {
99
"applicationType": "replicated.app",
1010
"customerID": "__customerID__",

integration/init_app/helm-github/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,6 @@
245245
"entitlements": {}
246246
}
247247
},
248-
"contentSHA": "275a18f485ae78a3e0c723da1625fa08d12bb27dc401c49f15231a31d939676e"
248+
"contentSHA": "687a05a7437c94d295cab91b748304d97ebb19e398cfed034e1659d81d852876"
249249
}
250250
}

integration/init_app/installation-template-func/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"v1": {
33
"config": {},
44
"upstream": "__upstream__",
5-
"contentSHA": "c8bbe58c7ee51e7185d42b717a6465cd3d9ec1b9f8eccda20f112fe54c155d3e",
5+
"contentSHA": "ac7606f1553dd7bcf0a47631cd673726c550f49754d631f079a868a51204d9bd",
66
"metadata": {
77
"applicationType": "replicated.app",
88
"customerID": "__customerID__",

integration/init_app/license-info/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@
7575
"buildTime": "0001-01-01T00:00:00Z",
7676
"dependencies": {}
7777
},
78-
"contentSHA": "a086cc2c22a907a2d6cc7b5bbc2eb8fe3530799f41e1c5add0ce8aac380e4042"
78+
"contentSHA": "c1e6486e6e3c2c4e49dac714aa8c151a024765575e20a8348541cf0833c70114"
7979
}
8080
}

integration/init_app/troubleshoot-ship-release/expected/.ship/state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"v1": {
33
"config": {},
44
"upstream": "__upstream__",
5-
"contentSHA": "71dd296d8fae1f07f66b05d2e12710eb58bd7725d55093e41b6501b592418b31",
5+
"contentSHA": "89cdef9a2ca2552ef5ce5be9048d6b1f75b4c59902770a4cd13d6d6b0cfd194f",
66
"metadata": {
77
"applicationType": "replicated.app",
88
"customerID": "__customerID__",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"v1": {
33
"config": {},
44
"upstream": "staging.replicated.app/some-cool-ci-tool?installation_id=3Z6uuPbVz6jTxRuXHn_l6UlYQz3hWz6-&customer_id=-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",
5-
"contentSHA": "6faeec976f37e880c5e70cf578412a57fbfda3b35bf8e6f73221fe5fe88f1058",
5+
"contentSHA": "9728a969294231e722662390ed73a8573a1af59f7a50bce21a8373612b69635e",
66
"metadata": {
77
"applicationType": "replicated.app",
88
"customerID": "-Am-_6i5pw0u4AbspOwKN4lZUCn49u_G",

pkg/specs/content.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package specs
33
import (
44
"context"
55
"crypto/sha256"
6+
"encoding/json"
67
"fmt"
78
"io/ioutil"
89
"net/http"
@@ -177,7 +178,13 @@ func (c *ContentProcessor) ReadContentSHAForWatch(ctx context.Context, upstream
177178
return "", errors.Wrap(err, "fetch release")
178179
}
179180

180-
return fmt.Sprintf("%x", sha256.Sum256([]byte(release.Spec))), nil
181+
release.Entitlements.Signature = "" // entitlements signature is not stable
182+
releaseJSON, err := json.Marshal(release)
183+
if err != nil {
184+
return "", errors.Wrap(err, "marshal release for sha256")
185+
}
186+
187+
return fmt.Sprintf("%x", sha256.Sum256(releaseJSON)), nil
181188
}
182189

183190
return "", errors.Errorf("Could not continue with application type %q of upstream %s", app.GetType(), upstream)

pkg/specs/interface_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ func TestResolver_ReadContentSHAForWatch(t *testing.T) {
356356
AppSlug: "",
357357
}).Return(&state2.ShipRelease{Spec: "its fake"}, nil)
358358
},
359-
expectSHA: "a9274e43955abe372d508864d19aa8be39872a39f44c8c5e2e04a4ef98c4aa04", // sha256.Sum256([]byte("its fake"))
359+
expectSHA: "ef1a4329e78b65e847e7428c3427f99b02a2d6c04ab3adb3910b9473b8bc7edb", // sha256.Sum256(json.Marshal(state2.ShipRelease{Spec: "its fake"}))
360360
},
361361
}
362362
for _, test := range tests {

pkg/specs/replicatedapp/local.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ func (r *resolver) resolveRunbookRelease(selector *Selector) (*state.ShipRelease
5656
Semver: semver,
5757
GithubContents: fakeGithubContents,
5858
Entitlements: *fakeEntitlements,
59+
Images: []state.Image{},
5960
}, nil
6061
}
6162

6263
func (r *resolver) loadLocalGitHubContents() ([]state.GithubContent, error) {
6364
debug := level.Debug(log.With(r.Logger, "method", "loadLocalGitHubContents"))
64-
var fakeGithubContents []state.GithubContent
65+
fakeGithubContents := []state.GithubContent{}
6566
for _, content := range r.SetGitHubContents {
6667
debug.Log("event", "githubcontents.set", "received", content)
6768
split := strings.Split(content, ":")

pkg/specs/replicatedapp/local_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestLoadLocalGitHubContents(t *testing.T) {
1919
{
2020
name: "none to set",
2121
githubContent: nil,
22-
expectContents: nil,
22+
expectContents: []state.GithubContent{},
2323
},
2424
{
2525
name: "set one file",

pkg/specs/replicatedapp/resolver.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
yaml "gopkg.in/yaml.v2"
2525
)
2626

27-
type shaSummer func([]byte) string
27+
type shaSummer func(release state.ShipRelease) string
2828
type dater func() string
2929
type resolver struct {
3030
Logger log.Logger
@@ -65,8 +65,14 @@ func NewAppResolver(
6565
RunbookReleaseSemver: v.GetString("release-semver"),
6666
IsEdit: v.GetBool("isEdit"),
6767
StateManager: stateManager,
68-
ShaSummer: func(bytes []byte) string {
69-
return fmt.Sprintf("%x", sha256.Sum256(bytes))
68+
ShaSummer: func(release state.ShipRelease) string {
69+
release.Entitlements.Signature = "" // entitlements signature is not stable
70+
releaseJSON, err := json.Marshal(release)
71+
if err != nil {
72+
panic(errors.Wrap(err, "marshal release to json for content sha"))
73+
}
74+
75+
return fmt.Sprintf("%x", sha256.Sum256(releaseJSON))
7076
},
7177
Dater: func() string {
7278
// format consistent with what we get from GQL
@@ -218,7 +224,7 @@ func (r *resolver) persistRelease(release *state.ShipRelease, license *license,
218224
return nil, errors.Wrap(err, "serialize app metadata")
219225
}
220226

221-
contentSHA := r.ShaSummer([]byte(release.Spec))
227+
contentSHA := r.ShaSummer(*release)
222228
if err := r.StateManager.SerializeContentSHA(contentSHA); err != nil {
223229
return nil, errors.Wrap(err, "serialize content sha")
224230
}

pkg/specs/replicatedapp/resolver_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ assets:
6060
CustomerID: "kfbr",
6161
InstallationID: "392",
6262
},
63-
shaSummer: func(bytes []byte) string {
63+
shaSummer: func(resolver state2.ShipRelease) string {
6464
return "abcdef"
6565
},
6666
license: &license{},

0 commit comments

Comments
 (0)