Add missed changes

Signed-off-by: Evans Mungai <mbuevans@gmail.com>
pull/32169/head
Evans Mungai 1 week ago
parent 24e03e3dab
commit e2704403af
No known key found for this signature in database
GPG Key ID: BBEB812143DD14E1

@ -23,6 +23,8 @@ import (
"strings"
"github.com/Masterminds/semver/v3"
"helm.sh/helm/v4/internal/test"
)
var (
@ -42,9 +44,14 @@ var (
gitTreeState = ""
)
var (
KubeVersionMajorTesting uint64
KubeVersionMinorTesting uint64
// Stub Kubernetes version values for use by any test path that needs a
// stable kube major/minor — for example, substituting into capabilities or
// client-go version strings so test output doesn't drift with the
// k8s.io/client-go version pinned in go.mod. Callers decide when to use
// them; they are not tied to any particular build tag or gating mechanism.
const (
KubeVersionMajorTesting uint64 = 1
KubeVersionMinorTesting uint64 = 20
)
// BuildInfo describes the compile time information.
@ -81,7 +88,7 @@ func Get() BuildInfo {
// Test builds don't include debug info / module info
// (And even if they did, we probably want a stable version during tests anyway)
// Return a default value for test builds
if KubeVersionMajorTesting != 0 && KubeVersionMinorTesting != 0 {
if test.IsTestMode() {
return fmt.Sprintf("v%d.%d", KubeVersionMajorTesting, KubeVersionMinorTesting)
}
@ -112,7 +119,7 @@ func Get() BuildInfo {
}
// HACK(bacongobbler): strip out GoVersion during a test run for consistent test output
if KubeVersionMajorTesting != 0 && KubeVersionMinorTesting != 0 {
if test.IsTestMode() {
v.GoVersion = ""
}
return v

@ -1,31 +0,0 @@
//go:build helmtest
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package version
// This file is only compiled when the `helmtest` build tag is set (applied by
// the Makefile to all test invocations). It seeds the testing-version
// sentinels so that production code paths in this package and in
// pkg/chart/common substitute stable values instead of attempting to read
// build info from a `go test` binary (which has no module info and would
// panic during package init).
func init() {
KubeVersionMajorTesting = 1
KubeVersionMinorTesting = 20
}

@ -28,6 +28,7 @@ import (
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
k8sversion "k8s.io/apimachinery/pkg/util/version"
"helm.sh/helm/v4/internal/test"
helmversion "helm.sh/helm/v4/internal/version"
)
@ -140,7 +141,7 @@ func makeDefaultCapabilities() (*Capabilities, error) {
// Test builds don't include debug info / module info
// (And even if they did, we probably want stable capabilities for tests anyway)
// Return a default value for test builds
if helmversion.KubeVersionMajorTesting != 0 && helmversion.KubeVersionMinorTesting != 0 {
if test.IsTestMode() {
return newCapabilities(helmversion.KubeVersionMajorTesting, helmversion.KubeVersionMinorTesting)
}

Loading…
Cancel
Save