diff --git a/pkg/chartutil/capabilities.go b/pkg/chartutil/capabilities.go index ec517817b..f4c896928 100644 --- a/pkg/chartutil/capabilities.go +++ b/pkg/chartutil/capabilities.go @@ -29,8 +29,10 @@ import ( ) var ( - k8sVersionMajor = 1 - k8sVersionMinor = 20 + // This should be set in the Makefile based on the version of client-go being imported. + // These constants will be overwritten with LDFLAGS (ldflags should be var and type string) + k8sVersionMajor = "1" + k8sVersionMinor = "20" // DefaultVersionSet is the default version set, which includes only Core V1 ("v1"). DefaultVersionSet = allKnownVersions() @@ -38,9 +40,9 @@ var ( // DefaultCapabilities is the default set of capabilities. DefaultCapabilities = &Capabilities{ KubeVersion: KubeVersion{ - Version: fmt.Sprintf("v%d.%d.0", k8sVersionMajor, k8sVersionMinor), - Major: strconv.Itoa(k8sVersionMajor), - Minor: strconv.Itoa(k8sVersionMinor), + Version: fmt.Sprintf("v%s.%s.0", k8sVersionMajor, k8sVersionMinor), + Major: k8sVersionMajor, + Minor: k8sVersionMinor, }, APIVersions: DefaultVersionSet, HelmVersion: helmversion.Get(), diff --git a/pkg/lint/rules/deprecations.go b/pkg/lint/rules/deprecations.go index b1a516cef..74cd1c906 100644 --- a/pkg/lint/rules/deprecations.go +++ b/pkg/lint/rules/deprecations.go @@ -18,6 +18,7 @@ package rules // import "helm.sh/helm/v3/pkg/lint/rules" import ( "fmt" + "strconv" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -27,9 +28,9 @@ import ( var ( // This should be set in the Makefile based on the version of client-go being imported. - // These constants will be overwritten with LDFLAGS - k8sVersionMajor = 1 - k8sVersionMinor = 20 + // These constants will be overwritten with LDFLAGS (ldflags should be var and type string) + k8sVersionMajor = "1" + k8sVersionMinor = "20" ) // deprecatedAPIError indicates than an API is deprecated in Kubernetes @@ -60,7 +61,9 @@ func validateNoDeprecations(resource *K8sYamlStruct) error { } return err } - if !deprecation.IsDeprecated(runtimeObject, k8sVersionMajor, k8sVersionMinor) { + currentVersionMajor, err := strconv.Atoi(k8sVersionMajor) + currentVersionMinor, err := strconv.Atoi(k8sVersionMinor) + if !deprecation.IsDeprecated(runtimeObject, currentVersionMajor, currentVersionMinor) { return nil } gvk := fmt.Sprintf("%s %s", resource.APIVersion, resource.Kind)