@@ -31,6 +31,7 @@ import (
31
31
"helm.sh/helm/v3/pkg/action"
32
32
"helm.sh/helm/v3/pkg/chart"
33
33
"helm.sh/helm/v3/pkg/chart/loader"
34
+ "helm.sh/helm/v3/pkg/chartutil"
34
35
"helm.sh/helm/v3/pkg/cli"
35
36
"helm.sh/helm/v3/pkg/registry"
36
37
. "helm.sh/helm/v3/pkg/repo"
@@ -45,6 +46,11 @@ const (
45
46
helmFieldTag = "helm"
46
47
)
47
48
49
+ var (
50
+ // KubeVersion is the target version of the kubernetes.
51
+ KubeVersion string = "v1.20.0"
52
+ )
53
+
48
54
// Manager is the Helm charts manager. The implementation is based on Helm SDK.
49
55
// The main purpose of Manager is:
50
56
// 1. Load the chart from remote charts and save them in cache directory.
@@ -318,13 +324,19 @@ func (r *Manager) isInChartsCache(packageName string) bool {
318
324
}
319
325
320
326
func (r * Manager ) newHelmClient (releaseName , namespace string ) (* action.Install , error ) {
327
+ kubeVersion , err := chartutil .ParseKubeVersion (KubeVersion )
328
+ if err != nil {
329
+ return nil , fmt .Errorf ("invalid kube version '%s': %s" , kubeVersion , err )
330
+ }
331
+
321
332
helmClient := action .NewInstall (new (action.Configuration ))
322
333
helmClient .DryRun = true
323
334
helmClient .ReleaseName = releaseName
324
335
helmClient .Replace = true
325
336
helmClient .ClientOnly = true
326
337
helmClient .IncludeCRDs = true
327
338
helmClient .Namespace = namespace
339
+ helmClient .KubeVersion = kubeVersion
328
340
329
341
return helmClient , nil
330
342
}
0 commit comments