Skip to content

Commit 9a8e210

Browse files
committed
add tests for kustomize config name handling
Signed-off-by: crabique <[email protected]>
1 parent 3ae8936 commit 9a8e210

File tree

6 files changed

+50
-9
lines changed

6 files changed

+50
-9
lines changed

pkg/update/filereader_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,23 @@ func TestScreeningLocalReader(t *testing.T) {
3333
}
3434
nodes, err := r.Read()
3535
g.Expect(err).ToNot(HaveOccurred())
36-
// the test fixture has three files that contain the marker:
37-
// - otherns.yaml
36+
// the test fixture has four files that contain the marker:
3837
// - marked.yaml
39-
// - kustomization.yaml
40-
g.Expect(len(nodes)).To(Equal(3))
38+
// - otherns.yaml
39+
// - kustomization.yml
40+
// - Kustomization
41+
g.Expect(len(nodes)).To(Equal(4))
4142
filesSeen := map[string]struct{}{}
4243
for i := range nodes {
4344
path, _, err := kioutil.GetFileAnnotations(nodes[i])
4445
g.Expect(err).ToNot(HaveOccurred())
4546
filesSeen[path] = struct{}{}
4647
}
4748
g.Expect(filesSeen).To(Equal(map[string]struct{}{
48-
"marked.yaml": {},
49-
"kustomization.yaml": {},
50-
"otherns.yaml": {},
49+
"marked.yaml": {},
50+
"otherns.yaml": {},
51+
"kustomization.yml": {},
52+
"Kustomization": {},
5153
}))
5254

5355
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This is not intended to be a working kustomization
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
resources:
5+
- irrelevant.yaml
6+
images:
7+
- name: container
8+
newName: index.repo.fake/updated # {"$imagepolicy": "automation-ns:policy:name"}
9+
newTag: v1.0.1 # {"$imagepolicy": "automation-ns:policy:tag"}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This is not intended to be a working kustomization
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
resources:
5+
- irrelevant.yaml
6+
images:
7+
- name: container
8+
newName: replaced # {"$imagepolicy": "automation-ns:policy:name"}
9+
newTag: v1 # {"$imagepolicy": "automation-ns:policy:tag"}

pkg/update/update_test.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,14 @@ func TestUpdateWithSetters(t *testing.T) {
8383

8484
expectedResult := Result{
8585
Files: map[string]FileResult{
86-
"kustomization.yaml": {
86+
"kustomization.yml": {
87+
Objects: map[ObjectIdentifier][]ImageRef{
88+
kustomizeResourceID: {
89+
expectedImageRef,
90+
},
91+
},
92+
},
93+
"Kustomization": {
8794
Objects: map[ObjectIdentifier][]ImageRef{
8895
kustomizeResourceID: {
8996
expectedImageRef,
@@ -111,7 +118,21 @@ func TestUpdateWithSetters(t *testing.T) {
111118
expectedResultV2 := ResultV2{
112119
ImageResult: expectedResult,
113120
FileChanges: map[string]ObjectChanges{
114-
"kustomization.yaml": {
121+
"kustomization.yml": {
122+
kustomizeResourceID: []Change{
123+
{
124+
OldValue: "replaced",
125+
NewValue: "index.repo.fake/updated",
126+
Setter: "automation-ns:policy:name",
127+
},
128+
{
129+
OldValue: "v1",
130+
NewValue: "v1.0.1",
131+
Setter: "automation-ns:policy:tag",
132+
},
133+
},
134+
},
135+
"Kustomization": {
115136
kustomizeResourceID: []Change{
116137
{
117138
OldValue: "replaced",

0 commit comments

Comments
 (0)