Merge pull request #10370 from mattfarina/fix-10367

Fix specifying of Kubernetes version from build scripts
pull/10379/head
Matt Farina 3 years ago committed by GitHub
commit 5f74c0e17f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,6 +26,9 @@ jobs:
- run: - run:
name: test name: test
command: make test-coverage command: make test-coverage
- run:
name: test build
command: make
- deploy: - deploy:
name: deploy name: deploy
command: .circleci/deploy.sh command: .circleci/deploy.sh

@ -29,8 +29,10 @@ import (
) )
var ( var (
k8sVersionMajor = 1 // The Kubernetes version can be set by LDFLAGS. In order to do that the value
k8sVersionMinor = 20 // must be a string.
k8sVersionMajor = "1"
k8sVersionMinor = "20"
// DefaultVersionSet is the default version set, which includes only Core V1 ("v1"). // DefaultVersionSet is the default version set, which includes only Core V1 ("v1").
DefaultVersionSet = allKnownVersions() DefaultVersionSet = allKnownVersions()
@ -38,9 +40,9 @@ var (
// DefaultCapabilities is the default set of capabilities. // DefaultCapabilities is the default set of capabilities.
DefaultCapabilities = &Capabilities{ DefaultCapabilities = &Capabilities{
KubeVersion: KubeVersion{ KubeVersion: KubeVersion{
Version: fmt.Sprintf("v%d.%d.0", k8sVersionMajor, k8sVersionMinor), Version: fmt.Sprintf("v%s.%s.0", k8sVersionMajor, k8sVersionMinor),
Major: strconv.Itoa(k8sVersionMajor), Major: k8sVersionMajor,
Minor: strconv.Itoa(k8sVersionMinor), Minor: k8sVersionMinor,
}, },
APIVersions: DefaultVersionSet, APIVersions: DefaultVersionSet,
HelmVersion: helmversion.Get(), HelmVersion: helmversion.Get(),

@ -18,6 +18,7 @@ package rules // import "helm.sh/helm/v3/pkg/lint/rules"
import ( import (
"fmt" "fmt"
"strconv"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
@ -27,9 +28,10 @@ import (
var ( var (
// This should be set in the Makefile based on the version of client-go being imported. // This should be set in the Makefile based on the version of client-go being imported.
// These constants will be overwritten with LDFLAGS // These constants will be overwritten with LDFLAGS. The version components must be
k8sVersionMajor = 1 // strings in order for LDFLAGS to set them.
k8sVersionMinor = 20 k8sVersionMajor = "1"
k8sVersionMinor = "20"
) )
// deprecatedAPIError indicates than an API is deprecated in Kubernetes // deprecatedAPIError indicates than an API is deprecated in Kubernetes
@ -60,7 +62,16 @@ func validateNoDeprecations(resource *K8sYamlStruct) error {
} }
return err return err
} }
if !deprecation.IsDeprecated(runtimeObject, k8sVersionMajor, k8sVersionMinor) { maj, err := strconv.Atoi(k8sVersionMajor)
if err != nil {
return err
}
min, err := strconv.Atoi(k8sVersionMinor)
if err != nil {
return err
}
if !deprecation.IsDeprecated(runtimeObject, maj, min) {
return nil return nil
} }
gvk := fmt.Sprintf("%s %s", resource.APIVersion, resource.Kind) gvk := fmt.Sprintf("%s %s", resource.APIVersion, resource.Kind)

Loading…
Cancel
Save