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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

crabique
Copy link

@crabique crabique commented Mar 8, 2025

Hi! Kustomize supports 3 slightly different variants of Kustomization configs file names in RecognizedKustomizationFileNames():

  • kustomization.yaml
  • kustomization.yml
  • Kustomization

This PR adds support for the last one, as at the moment it would be optimized away by the controller and ignored.

I also changed the existing kustomization.yaml test file extension as there was not a single .yml file in the fixture.
It seemed appropriate for the Kustomize one as it's also one of the canonically recognized names.

@crabique crabique force-pushed the add/canonical-kustomization-support branch from 9fc807d to 0014c64 Compare March 8, 2025 00:39
@matheuscscp
Copy link
Member

Hi @crabique, thanks very much for the contribution!

The tests are failing, below is the output from the GitHub Action. Please run make test locally to iterate on the tests and push only when the tests are passing, this avoids wasting Flux's GH Actions usage limits 🙏

make test
cd api; rm -f go.sum; go mod tidy -compat=1.23
rm -f go.sum; go mod tidy -compat=1.23
cd api; go test -race ./... -coverprofile cover.out
	github.com/fluxcd/image-automation-controller/api/v1beta1		coverage: 0.0% of statements
	github.com/fluxcd/image-automation-controller/api/v1beta2		coverage: 0.0% of statements
mkdir -p cache
curl -s --fail https://raw.githubusercontent.com/fluxcd/image-reflector-controller/v0.3[4](https://github.com/fluxcd/image-automation-controller/actions/runs/13731952501/job/38491195141?pr=864#step:4:5).0/config/crd/bases/image.toolkit.fluxcd.io_imagepolicies.yaml \
	-o cache/imagepolicies_v0.34.0.yaml
mkdir -p internal/controller/testdata/crds
cp cache/imagepolicies_v0.34.0.yaml internal/controller/testdata/crds/imagepolicies.yaml
mkdir -p cache
curl -s --fail https://raw.githubusercontent.com/fluxcd/source-controller/v1.[5](https://github.com/fluxcd/image-automation-controller/actions/runs/13731952501/job/38491195141?pr=864#step:4:6).0/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml \
	-o cache/gitrepositories_v1.5.0.yaml
mkdir -p internal/controller/testdata/crds
cp cache/gitrepositories_v1.5.0.yaml internal/controller/testdata/crds/gitrepositories.yaml
go: creating new go.mod: module tmp
Downloading sigs.k8s.io/controller-tools/cmd/[email protected][6](https://github.com/fluxcd/image-automation-controller/actions/runs/13731952501/job/38491195141?pr=864#step:4:7).1
cd api; /home/runner/work/image-automation-controller/image-automation-controller/build/gobin/controller-gen object:headerFile="../hack/boilerplate.go.txt" paths="./..."
go fmt ./...
pkg/update/filereader_test.go
cd api; go fmt ./...
go vet ./...
cd api; go vet ./...
/home/runner/work/image-automation-controller/image-automation-controller/build/gobin/controller-gen crd:crdVersions=v1 rbac:roleName=manager-role paths="./..." output:crd:artifacts:config="config/crd/bases"
cd api; /home/runner/work/image-automation-controller/image-automation-controller/build/gobin/controller-gen crd:crdVersions=v1 rbac:roleName=manager-role paths="./..." output:crd:artifacts:config="../config/crd/bases"
go: creating new go.mod: module tmp
Downloading github.com/ahmetb/gen-crd-api-reference-docs@e32[7](https://github.com/fluxcd/image-automation-controller/actions/runs/13731952501/job/38491195141?pr=864#step:4:8)d0730470cbd61b06300f81c5fcf91c23c113
/home/runner/work/image-automation-controller/image-automation-controller/build/gobin/gen-crd-api-reference-docs -api-dir=./api/v1beta2 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/v1beta2/image-automation.md
I0310 13:17:44.43667[8](https://github.com/fluxcd/image-automation-controller/actions/runs/13731952501/job/38491195141?pr=864#step:4:9)   17361 main.go:132] parsing go packages in directory ./api/v1beta2
I0310 13:17:46.579050   17361 main.go:234] using package=./api/v1beta2
I0310 13:17:46.584817   17361 main.go:170] written to ./docs/api/v1beta2/image-automation.md
go: creating new go.mod: module tmp
Downloading sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
go: downloading sigs.k8s.io/controller-runtime v0.20.3
go: downloading sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20250310021545-f80bc5dbf8f7
go: sigs.k8s.io/controller-runtime/tools/[email protected] requires go >= 1.24.0; switching to go1.24.1
go: downloading go1.24.1 (linux/amd64)
mkdir -p /home/runner/work/image-automation-controller/image-automation-controller/build/testbin
/home/runner/work/image-automation-controller/image-automation-controller/build/gobin/setup-envtest use latest --arch=amd64 --bin-dir=/home/runner/work/image-automation-controller/image-automation-controller/build/testbin
Version: 1.32.0
OS/Arch: linux/amd64
sha512: 3a[9](https://github.com/fluxcd/image-automation-controller/actions/runs/13731952501/job/38491195141?pr=864#step:4:10)584af30d041c42893d8f7a860aa434976d4aee479cf2e9a50a9e5677dcc83d3012a2146a6feb5b2e95a7b3c6f657ae9c591745981262da8b06e4b61dcdf17
Path: /home/runner/work/image-automation-controller/image-automation-controller/build/testbin/k8s/1.32.0-linux-amd64
chmod -R u+w /home/runner/work/image-automation-controller/image-automation-controller/build/testbin
KUBEBUILDER_ASSETS="/home/runner/work/image-automation-controller/image-automation-controller/build/testbin/k8s/1.32.0-linux-amd64" \
go test -ldflags "-s -w" -tags 'netgo,osusergo,static_build' -race ./... -coverprofile cover.out
	github.com/fluxcd/image-automation-controller		coverage: 0.0% of statements
	github.com/fluxcd/image-automation-controller/internal/features		coverage: 0.0% of statements
	github.com/fluxcd/image-automation-controller/internal/testutil		coverage: 0.0% of statements
ok  	github.com/fluxcd/image-automation-controller/internal/controller	29.424s	coverage: 83.0% of statements
ok  	github.com/fluxcd/image-automation-controller/internal/policy	1.122s	coverage: 92.3% of statements
ok  	github.com/fluxcd/image-automation-controller/internal/source	21.067s	coverage: 86.8% of statements
ok  	github.com/fluxcd/image-automation-controller/pkg/test	1.016s	coverage: 74.6% of statements
--- FAIL: TestUpdateWithSetters (0.01s)
    files.go:33: 
        Expect no files in /tmp/TestUpdateWithSetters2193376333/001 but not in testdata/setters/expected
        Expected
            <[]string | len:2, cap:2>: ["/Kustomization", "/kustomization.yml"]
        to be empty
FAIL
coverage: 87.5% of statements
FAIL	github.com/fluxcd/image-automation-controller/pkg/update	0.036s
FAIL
make: *** [Makefile:[11](https://github.com/fluxcd/image-automation-controller/actions/runs/13731952501/job/38491195141?pr=864#step:4:12)3: test] Error 1

@crabique crabique force-pushed the add/canonical-kustomization-support branch from 0014c64 to 166c643 Compare March 10, 2025 15:25
@crabique crabique force-pushed the add/canonical-kustomization-support branch from 166c643 to 9a8e210 Compare March 10, 2025 15:28
@crabique
Copy link
Author

Hi @matheuscscp! Thanks, I fixed the tests.

Copy link
Member

@matheuscscp matheuscscp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @crabique!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants