MCPcopy Index your code
hub / github.com/helm/helm / Get

Function Get

internal/version/version.go:79–120  ·  view source on GitHub ↗

Get returns build info

()

Source from the content-addressed store, hash-verified

77
78// Get returns build info
79func Get() BuildInfo {
80
81 makeKubeClientVersionString := func() string {
82 // Test builds don't include debug info / module info
83 // (And even if they did, we probably want a stable version during tests anyway)
84 // Return a default value for test builds
85 if testing.Testing() {
86 return kubeClientGoVersionTesting
87 }
88
89 vstr, err := K8sIOClientGoModVersion()
90 if err != nil {
91 slog.Error("failed to retrieve k8s.io/client-go version", slog.Any("error", err))
92 return ""
93 }
94
95 v, err := semver.NewVersion(vstr)
96 if err != nil {
97 slog.Error("unable to parse k8s.io/client-go version", slog.String("version", vstr), slog.Any("error", err))
98 return ""
99 }
100
101 kubeClientVersionMajor := v.Major() + 1
102 kubeClientVersionMinor := v.Minor()
103
104 return fmt.Sprintf("v%d.%d", kubeClientVersionMajor, kubeClientVersionMinor)
105 }
106
107 v := BuildInfo{
108 Version: GetVersion(),
109 GitCommit: gitCommit,
110 GitTreeState: gitTreeState,
111 GoVersion: runtime.Version(),
112 KubeClientVersion: makeKubeClientVersionString(),
113 }
114
115 // HACK(bacongobbler): strip out GoVersion during a test run for consistent test output
116 if flag.Lookup("test.v") != nil {
117 v.GoVersion = ""
118 }
119 return v
120}

Callers 2

runMethod · 0.92
formatVersionFunction · 0.92

Calls 5

K8sIOClientGoModVersionFunction · 0.85
GetVersionFunction · 0.85
VersionMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected