mirror of
https://github.com/helm/helm.git
synced 2026-04-08 18:36:28 -04:00
Merge pull request #31351 from gjenkins8/gjenkins/helm_version_kubeversion
feat: `helm version` print Kubernetes (client-go) version
This commit is contained in:
commit
2cfd41ec28
3 changed files with 16 additions and 5 deletions
2
Makefile
2
Makefile
|
|
@ -69,6 +69,8 @@ LDFLAGS += -X helm.sh/helm/v4/pkg/internal/v3/lint/rules.k8sVersionMajor=$(K8S_M
|
|||
LDFLAGS += -X helm.sh/helm/v4/pkg/internal/v3/lint/rules.k8sVersionMinor=$(K8S_MODULES_MINOR_VER)
|
||||
LDFLAGS += -X helm.sh/helm/v4/pkg/chart/common/util.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER)
|
||||
LDFLAGS += -X helm.sh/helm/v4/pkg/chart/common/util.k8sVersionMinor=$(K8S_MODULES_MINOR_VER)
|
||||
LDFLAGS += -X helm.sh/helm/v4/internal/version.kubeClientVersionMajor=$(K8S_MODULES_MAJOR_VER)
|
||||
LDFLAGS += -X helm.sh/helm/v4/internal/version.kubeClientVersionMinor=$(K8S_MODULES_MINOR_VER)
|
||||
|
||||
.PHONY: all
|
||||
all: build
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package version // import "helm.sh/helm/v4/internal/version"
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -37,6 +38,11 @@ var (
|
|||
gitCommit = ""
|
||||
// gitTreeState is the state of the git tree
|
||||
gitTreeState = ""
|
||||
|
||||
// The Kubernetes version can be set by LDFLAGS. In order to do that the value
|
||||
// must be a string.
|
||||
kubeClientVersionMajor = ""
|
||||
kubeClientVersionMinor = ""
|
||||
)
|
||||
|
||||
// BuildInfo describes the compile time information.
|
||||
|
|
@ -49,6 +55,8 @@ type BuildInfo struct {
|
|||
GitTreeState string `json:"git_tree_state,omitempty"`
|
||||
// GoVersion is the version of the Go compiler used.
|
||||
GoVersion string `json:"go_version,omitempty"`
|
||||
// KubeClientVersion is the version of client-go Helm was build with
|
||||
KubeClientVersion string `json:"kube_client_version"`
|
||||
}
|
||||
|
||||
// GetVersion returns the semver string of the version
|
||||
|
|
@ -67,10 +75,11 @@ func GetUserAgent() string {
|
|||
// Get returns build info
|
||||
func Get() BuildInfo {
|
||||
v := BuildInfo{
|
||||
Version: GetVersion(),
|
||||
GitCommit: gitCommit,
|
||||
GitTreeState: gitTreeState,
|
||||
GoVersion: runtime.Version(),
|
||||
Version: GetVersion(),
|
||||
GitCommit: gitCommit,
|
||||
GitTreeState: gitTreeState,
|
||||
GoVersion: runtime.Version(),
|
||||
KubeClientVersion: fmt.Sprintf("v%s.%s", kubeClientVersionMajor, kubeClientVersionMinor),
|
||||
}
|
||||
|
||||
// HACK(bacongobbler): strip out GoVersion during a test run for consistent test output
|
||||
|
|
|
|||
2
pkg/cmd/testdata/output/version.txt
vendored
2
pkg/cmd/testdata/output/version.txt
vendored
|
|
@ -1 +1 @@
|
|||
version.BuildInfo{Version:"v4.0", GitCommit:"", GitTreeState:"", GoVersion:""}
|
||||
version.BuildInfo{Version:"v4.0", GitCommit:"", GitTreeState:"", GoVersion:"", KubeClientVersion:"v."}
|
||||
|
|
|
|||
Loading…
Reference in a new issue