MCPcopy Index your code
hub / github.com/databus23/helm-diff / getHelmVersion

Function getHelmVersion

cmd/helm.go:80–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78)
79
80func getHelmVersion() (*semver.Version, error) {
81 cmd := exec.Command(os.Getenv("HELM_BIN"), "version")
82 debugPrint("Executing %s", strings.Join(cmd.Args, " "))
83 output, err := cmd.CombinedOutput()
84 if err != nil {
85 return nil, fmt.Errorf("Failed to run `%s version`: %w", os.Getenv("HELM_BIN"), err)
86 }
87 versionOutput := string(output)
88
89 matches := helmVersionRE.FindStringSubmatch(versionOutput)
90 if matches == nil {
91 return nil, fmt.Errorf("Failed to find version in output %#v", versionOutput)
92 }
93 helmVersion, err := semver.NewVersion(matches[1])
94 if err != nil {
95 return nil, fmt.Errorf("Failed to parse version %#v: %w", matches[1], err)
96 }
97
98 return helmVersion, nil
99}
100
101func isHelmVersionAtLeast(versionToCompareTo *semver.Version) (bool, error) {
102 helmVersion, err := getHelmVersion()

Callers 2

isHelmVersionAtLeastFunction · 0.85

Calls 1

debugPrintFunction · 0.85

Tested by

no test coverage detected