Repository navigation
fix: honor release kubeVersion over the detected one in diff - #2842
Conversation
When the cluster version is auto-detected, helmfile diff passed it as --kube-version even if the release sets its own kubeVersion, so the release value was dropped. Pass the detected version only when the release leaves kubeVersion unset, as the path with disableAutoDetectedKubeVersionForDiff already does. Signed-off-by: spicysharkco <[email protected]>
yxxhero
left a comment
There was a problem hiding this comment.
Thanks! Verified: since #2276 the default diff path unconditionally set kubeVersionForDiff = opt.DetectedKubeVersion, and getKubeVersion (pkg/state/state.go:4745-4755) gives the explicit parameter top priority — so a successful detection shadowed release.KubeVersion. The new guard (release.KubeVersion == "" && ...) makes the release value win even with auto-detection enabled, matching the documented "Per-release kube version overrides top-level" semantics and the existing disableAutoDetectedKubeVersionForDiff: true behavior.
Also confirmed diff is the only auto-detecting path (flagsForTemplate and the chartify path use getKubeVersion with the CLI flag only; lint passes no --kube-version), so the diff-only scope is correct. The new test fails on the parent commit (old code would emit --kube-version 1.30.2). Nothing blocking from my side.
Non-blocking notes:
- The indirection is correct but non-obvious: when the release sets
kubeVersion,kubeVersionForDiffstays""and the value is applied later insidegetKubeVersion's fallback chain. A one-line comment could help future readers. disableAutoDetectedKubeVersionForDiffhas no unit-test coverage anywhere in the repo (pre-existing gap, out of scope here).- Optional:
docs/configuration.mdcould mention that a releasekubeVersionalso suppresses the auto-detected version for diff.
Problem
With:
and no top-level
kubeVersion,helmfile diffpasses the detected cluster version,1.30.2, as--kube-version 1.30.2. The release value is dropped. WithdisableAutoDetectedKubeVersionForDiff: truethe same release gets--kube-version 1.28, and the docs say a releasekubeVersionoverrides the top-level one.Solution
The auto-detect branch took the detected version whenever one was set. It now takes it only when the release leaves
kubeVersionunset, so a release without one still gets the detected version.detectKubeVersionalready returns nothing when the top-levelkubeVersionis set.Test
TestHelmState_DiffFlagsgets two rows: the detected version alone, and release1.28with detected1.30.2.go test ./pkg/state -run '^TestHelmState_DiffFlags$' -count=1 -p 1With the fix: 7 of 7 rows pass. With the fix reverted, the release row fails with
= [--kube-version 1.30.2], want [--kube-version 1.28]and the other 6 pass.