-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
helmver.go
56 lines (52 loc) · 1.61 KB
/
helmver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package helm
import (
"os"
"path"
)
var (
// HelmV3 represents helm V3 specific settings
HelmV3 = HelmVer{
binaryName: "helm",
templateNameArg: "--name-template",
kubeVersionSupported: true,
showCommand: "show",
pullCommand: "pull",
initSupported: false,
getPostTemplateCallback: cleanupChartLockFile,
includeCrds: true,
insecureSkipVerifySupported: true,
helmPassCredentialsSupported: true,
}
)
// workaround for Helm3 bug. Remove after https://github.com/helm/helm/issues/6870 is fixed.
// The `helm template` command generates Chart.lock after which `helm dependency build` does not work
// As workaround removing lock file unless it exists before running helm template
func cleanupChartLockFile(chartPath string) (func(), error) {
exists := true
lockPath := path.Join(chartPath, "Chart.lock")
if _, err := os.Stat(lockPath); err != nil {
if os.IsNotExist(err) {
exists = false
} else {
return nil, err
}
}
return func() {
if !exists {
_ = os.Remove(lockPath)
}
}, nil
}
// HelmVer contains Helm version specific settings such as helm binary and command names
type HelmVer struct {
binaryName string
initSupported bool
templateNameArg string
showCommand string
pullCommand string
kubeVersionSupported bool
getPostTemplateCallback func(chartPath string) (func(), error)
includeCrds bool
insecureSkipVerifySupported bool
helmPassCredentialsSupported bool
}