Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for all recognized Kustomize config file names #864

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/update/filereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r *ScreeningLocalReader) Read() ([]*yaml.RNode, error) {
return nil
}

if ext := filepath.Ext(p); ext != ".yaml" && ext != ".yml" {
if ext := filepath.Ext(p); ext != ".yaml" && ext != ".yml" && filepath.Base(p) != "Kustomization" {
return nil
}

Expand Down
16 changes: 9 additions & 7 deletions pkg/update/filereader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ func TestScreeningLocalReader(t *testing.T) {
}
nodes, err := r.Read()
g.Expect(err).ToNot(HaveOccurred())
// the test fixture has three files that contain the marker:
// - otherns.yaml
// the test fixture has four files that contain the marker:
// - marked.yaml
// - kustomization.yaml
g.Expect(len(nodes)).To(Equal(3))
// - otherns.yaml
// - kustomization.yml
// - Kustomization
g.Expect(len(nodes)).To(Equal(4))
filesSeen := map[string]struct{}{}
for i := range nodes {
path, _, err := kioutil.GetFileAnnotations(nodes[i])
g.Expect(err).ToNot(HaveOccurred())
filesSeen[path] = struct{}{}
}
g.Expect(filesSeen).To(Equal(map[string]struct{}{
"marked.yaml": {},
"kustomization.yaml": {},
"otherns.yaml": {},
"marked.yaml": {},
"otherns.yaml": {},
"kustomization.yml": {},
"Kustomization": {},
}))

}
9 changes: 9 additions & 0 deletions pkg/update/testdata/setters/expected/Kustomization
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is not intended to be a working kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- irrelevant.yaml
images:
- name: container
newName: index.repo.fake/updated # {"$imagepolicy": "automation-ns:policy:name"}
newTag: v1.0.1 # {"$imagepolicy": "automation-ns:policy:tag"}
9 changes: 9 additions & 0 deletions pkg/update/testdata/setters/original/Kustomization
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is not intended to be a working kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- irrelevant.yaml
images:
- name: container
newName: replaced # {"$imagepolicy": "automation-ns:policy:name"}
newTag: v1 # {"$imagepolicy": "automation-ns:policy:tag"}
25 changes: 23 additions & 2 deletions pkg/update/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ func TestUpdateWithSetters(t *testing.T) {

expectedResult := Result{
Files: map[string]FileResult{
"kustomization.yaml": {
"kustomization.yml": {
Objects: map[ObjectIdentifier][]ImageRef{
kustomizeResourceID: {
expectedImageRef,
},
},
},
"Kustomization": {
Objects: map[ObjectIdentifier][]ImageRef{
kustomizeResourceID: {
expectedImageRef,
Expand Down Expand Up @@ -111,7 +118,21 @@ func TestUpdateWithSetters(t *testing.T) {
expectedResultV2 := ResultV2{
ImageResult: expectedResult,
FileChanges: map[string]ObjectChanges{
"kustomization.yaml": {
"kustomization.yml": {
kustomizeResourceID: []Change{
{
OldValue: "replaced",
NewValue: "index.repo.fake/updated",
Setter: "automation-ns:policy:name",
},
{
OldValue: "v1",
NewValue: "v1.0.1",
Setter: "automation-ns:policy:tag",
},
},
},
"Kustomization": {
kustomizeResourceID: []Change{
{
OldValue: "replaced",
Expand Down
Loading