fix: graceful fallback when debug.BuildInfo is unavailable

When Helm is built with toolchains other than `go build` (e.g. Bazel),
`debug.ReadBuildInfo()` returns false, causing a panic during
DefaultCapabilities initialization. Fall back to the default Kubernetes
version (v1.20.0) instead of panicking.

Fixes #31904

Signed-off-by: Terry Howe <thowe@nvidia.com>
pull/31912/head
Terry Howe 2 months ago
parent e31a078e6e
commit 6e445ec679
No known key found for this signature in database

@ -152,7 +152,9 @@ func makeDefaultCapabilities() (*Capabilities, error) {
vstr, err := helmversion.K8sIOClientGoModVersion()
if err != nil {
return nil, fmt.Errorf("failed to retrieve k8s.io/client-go version: %w", err)
// Build info may be unavailable when compiled with toolchains other
// than "go build" (e.g. Bazel). Fall back to a safe default.
return newCapabilities(kubeVersionMajorTesting, kubeVersionMinorTesting)
}
v, err := semver.NewVersion(vstr)

Loading…
Cancel
Save