8000
Skip to content

fix: preserve vendor suffixes in KubeVersion.GitVersion#31528

Merged
gjenkins8 merged 1 commit intohelm:mainfrom
benoittgt:31423-git-version
Dec 8, 2025
Merged

fix: preserve vendor suffixes in KubeVersion.GitVersion#31528
gjenkins8 merged 1 commit intohelm:mainfrom
benoittgt:31423-git-version

Conversation

@benoittgt
Copy link
Copy Markdown
Contributor
@benoittgt benoittgt commented Nov 18, 2025

What this PR does / why we need it:

Helm 3.19.0 introduced a regression where vendor-specific suffixes (e.g., -gke.1245000, -eks-4096722, +) are stripped from .Capabilities.KubeVersion.GitVersion, breaking charts that detect managed Kubernetes platforms (#31423).

The root cause was using k8sversion.ParseGeneric().String() which intentionally discards vendor suffixes. It is good thing for comparaison but no when return the full GitVersion. The fix preserves the original version string while still using ParseGeneric() for validation and Major/Minor extraction.

I am not super happy with the fix, especially with String(), but I was not able to find easier path.

Fixes #31423
Related to #31063, #31078

Special notes for your reviewer:

Script I used to check the behavior:

#!/bin/bash
set -e

make build

mkdir -p /tmp/test-chart/templates
cat > /tmp/test-chart/Chart.yaml <<EOF
apiVersion: v2
name: test-chart
version: 0.1.0
kubeVersion: ">= 1.21.0"
EOF

cat > /tmp/test-chart/templates/test.yaml <<'EOF'
version: {{ .Capabilities.KubeVersion.Version }}
EOF

./bin/helm template /tmp/test-chart --kube-version v1.33.4-gke.1245000 | grep -q "version: v1.33.4-gke.1245000" || {
  echo "FAIL: GKE suffix not preserved"
  exit 1
}

./bin/helm template /tmp/test-chart --kube-version 1.28+ | grep -q "version: v1.28+" || {
  echo "FAIL: + not preserved"
  exit 1
}

rm -rf /tmp/test-chart
echo "Looks good!"

Tiny increase in coverage 🐜 :

ok      helm.sh/helm/v4/pkg/chart/common        0.333s  coverage: 76.5% of statements
ok      helm.sh/helm/v4/pkg/chart/common        0.389s  coverage: 77.0% of statements

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so). Not sure it needs to be documented
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 18, 2025
// String implements fmt.Stringer.
// Returns the normalized version for constraint checking.
func (kv *KubeVersion) String() string {
if kv.normalizedVersion != "" {
Copy link
Copy Markdown
Contributor Author
@benoittgt benoittgt Nov 18, 2025

Choose a reason for hiding this comment

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

That’s the part I’m the least convinced about. But at least is backward compatible and produce something relevant.

Helm 3.19.0 introduced a regression where vendor-specific suffixes
(e.g., -gke.1245000, -eks-4096722, +) are stripped from
.Capabilities.KubeVersion.GitVersion, breaking charts that detect
managed Kubernetes platforms.

The root cause was using k8sversion.ParseGeneric().String() which
intentionally discards vendor suffixes. The fix stores both the full
version (with vendor suffix) and a normalized version. String() returns
the normalized version for constraint checking (e.g., ">= 1.21.0"),
while Version/GitVersion preserve the full string for template access.

Fixes helm#31423
Related to helm#31063, helm#31078

Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
@benoittgt benoittgt marked this pull request as ready for review November 18, 2025 14:30
Copy link
Copy Markdown
Member
@robertsirc robertsirc left a comment

Choose a reason for hiding this comment

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

LGTM

@robertsirc robertsirc added the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Nov 20, 2025
Copy link
Copy Markdown
Contributor
@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

/lgtm

Full tests pass for me

Copy link
Copy Markdown
Contributor
@sabre1041 sabre1041 left a comment

Choose a reason for hiding this comment

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

LGTM

@benoittgt
Copy link
Copy Markdown
Contributor Author

I have two approvals. Is it possible to merge @sabre1041 ?

@gjenkins8 gjenkins8 merged commit 3165e54 into helm:main Dec 8, 2025
5 checks passed
@gjenkins8 gjenkins8 removed the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Dec 8, 2025
@benoittgt benoittgt deleted the 31423-git-version branch December 8, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Helm 3.19.0: .Capabilities.KubeVersion.GitVersion renders incorrectly

5 participants

0