fix: for kustomize.buildOptions.<version> per-version build options are never applied #27673#27723
fix: for kustomize.buildOptions.<version> per-version build options are never applied #27673#27723Knickkennedy wants to merge 6 commits intoargoproj:masterfrom
Conversation
Root cause: minWidth: fit-content expands container with content. Fix: Remove fit-content, add overflowWrap: break-word. Signed-off-by: Knicholas Kennedy <knicholas.kennedy@gmail.com>
…as previously missing. I mirrored GetKustomizeBinaryPath for inspiration. I fixed two call sites where k.Build() was always receiving q.KustomizeOptions but now we check GetKustomizeBuildOptions first to ensure that we're picking up build options. We swap before passing it to Build() to avoid mutating shared options. I added unit tests based on the other unit tests I've seen ArgoCD do. Signed-off-by: Knicholas Kennedy <knicholas.kennedy@gmail.com>
🔴 Preview Environment stopped on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #27723 +/- ##
=======================================
Coverage 63.81% 63.81%
=======================================
Files 419 419
Lines 57221 57241 +20
=======================================
+ Hits 36513 36526 +13
- Misses 17292 17297 +5
- Partials 3416 3418 +2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Pull request overview
Fixes a reposerver bug where kustomize.buildOptions.<version> (per-version Kustomize build options from argocd-cm) are parsed into settings but never applied to the actual kustomize build invocation when an Application selects a named Kustomize version.
Changes:
- Added
settings.GetKustomizeBuildOptions(...)to resolve effective build options for a givenApplicationSource+KustomizeOptions. - Added unit tests for build-options resolution in
util/settings. - Updated reposerver Kustomize manifest generation (and app-details population) to apply the effective per-version build options without mutating shared
KustomizeOptions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| util/settings/settings.go | Adds helper to resolve effective (per-version vs global) Kustomize build options. |
| util/settings/settings_test.go | Adds unit tests covering per-version and fallback build-options resolution. |
| reposerver/repository/repository.go | Applies resolved per-version build options to Kustomize builds in manifest generation and app-details paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| kustomizeOpts := q.KustomizeOptions | ||
| if kustomizeOpts != nil { | ||
| if effectiveBuildOptions := settings.GetKustomizeBuildOptions(kustomizeOpts, *q.ApplicationSource); effectiveBuildOptions != kustomizeOpts.BuildOptions { | ||
| optsCopy := *kustomizeOpts | ||
| optsCopy.BuildOptions = effectiveBuildOptions | ||
| kustomizeOpts = &optsCopy | ||
| } | ||
| } |
| kustomizeOpts := q.KustomizeOptions | ||
| if kustomizeOpts != nil { | ||
| if effectiveBuildOptions := settings.GetKustomizeBuildOptions(kustomizeOpts, *q.Source); effectiveBuildOptions != kustomizeOpts.BuildOptions { | ||
| optsCopy := *kustomizeOpts | ||
| optsCopy.BuildOptions = effectiveBuildOptions | ||
| kustomizeOpts = &optsCopy | ||
| } | ||
| } | ||
| _, images, _, err := k.Build(q.Source.Kustomize, kustomizeOpts, env, nil) |
ranakan19
left a comment
There was a problem hiding this comment.
Could you provide Repo-server log output as mentioned in the linked issue after this change?
It would be nice to have a test case in reposerver/repository/repository_test.go for this, is it possible to add that?
probably add a test case similar to https://github.com/argoproj/argo-cd/blob/master/reposerver/repository/repository_test.go#L281 with buildOption?
Checklist:
I ran the unit tests with the updated unit tests as followed:
go test ./util/settings/... -run "Test_GetKustomize" -v 2>&1 === RUN Test_GetKustomizeBinaryPath === RUN Test_GetKustomizeBinaryPath/VersionDoesNotExist === RUN Test_GetKustomizeBinaryPath/DefaultBuildOptions === RUN Test_GetKustomizeBinaryPath/VersionExists === RUN Test_GetKustomizeBinaryPath/VersionExistsWithBuildOption === RUN Test_GetKustomizeBinaryPath/ExplicitVersionSet time="2026-05-06T13:46:21-04:00" level=warning msg="kustomizeOptions.binaryPath is deprecated, use KustomizeOptions.versions instead" --- PASS: Test_GetKustomizeBinaryPath (0.00s) --- PASS: Test_GetKustomizeBinaryPath/VersionDoesNotExist (0.00s) --- PASS: Test_GetKustomizeBinaryPath/DefaultBuildOptions (0.00s) --- PASS: Test_GetKustomizeBinaryPath/VersionExists (0.00s) --- PASS: Test_GetKustomizeBinaryPath/VersionExistsWithBuildOption (0.00s) --- PASS: Test_GetKustomizeBinaryPath/ExplicitVersionSet (0.00s) === RUN Test_GetKustomizeBuildOptions === RUN Test_GetKustomizeBuildOptions/NilOptions === RUN Test_GetKustomizeBuildOptions/NoVersionRequested === RUN Test_GetKustomizeBuildOptions/VersionWithBuildOptions === RUN Test_GetKustomizeBuildOptions/VersionWithoutBuildOptions === RUN Test_GetKustomizeBuildOptions/UnknownVersion --- PASS: Test_GetKustomizeBuildOptions (0.00s) --- PASS: Test_GetKustomizeBuildOptions/NilOptions (0.00s) --- PASS: Test_GetKustomizeBuildOptions/NoVersionRequested (0.00s) --- PASS: Test_GetKustomizeBuildOptions/VersionWithBuildOptions (0.00s) --- PASS: Test_GetKustomizeBuildOptions/VersionWithoutBuildOptions (0.00s) --- PASS: Test_GetKustomizeBuildOptions/UnknownVersion (0.00s) PASS ok github.com/argoproj/argo-cd/v3/util/settings (cached)I believe this is all that is needed because we just needed to confirm that GetKustomizeBuildOptions correctly resolves the right build options string for a given version, this logic previously didn't exist at a code level. This is a fairly small, mechanically straightforward change. I'm happy to add more information or confirmation that these changes are correct/wrong depending on what the team desires.
fixes #27673 / fixes 27673