From 65c9a7513ab85f7ed24c4f1e257c44e25ac1dc8f Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Thu, 5 Dec 2019 22:00:19 +0200 Subject: [PATCH] helm v3 --- pkg/apis/helm.cattle.io/v1/doc.go | 1 - pkg/apis/helm.cattle.io/v1/types.go | 1 + pkg/helm/controller.go | 21 +++++++++++++++++---- pkg/helm/controller_test.go | 4 ++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pkg/apis/helm.cattle.io/v1/doc.go b/pkg/apis/helm.cattle.io/v1/doc.go index d8a07691..6bd5f6a5 100644 --- a/pkg/apis/helm.cattle.io/v1/doc.go +++ b/pkg/apis/helm.cattle.io/v1/doc.go @@ -18,5 +18,4 @@ limitations under the License. // +k8s:deepcopy-gen=package // +groupName=helm.cattle.io - package v1 diff --git a/pkg/apis/helm.cattle.io/v1/types.go b/pkg/apis/helm.cattle.io/v1/types.go index 21045a00..ccb05e35 100644 --- a/pkg/apis/helm.cattle.io/v1/types.go +++ b/pkg/apis/helm.cattle.io/v1/types.go @@ -23,6 +23,7 @@ type HelmChartSpec struct { Repo string `json:"repo,omitempty"` Set map[string]intstr.IntOrString `json:"set,omitempty"` ValuesContent string `json:"valuesContent,omitempty"` + HelmVersion string `json:"helmVersion,omitempty"` } type HelmChartStatus struct { diff --git a/pkg/helm/controller.go b/pkg/helm/controller.go index 6a463313..6954acc0 100644 --- a/pkg/helm/controller.go +++ b/pkg/helm/controller.go @@ -39,7 +39,7 @@ type Controller struct { } const ( - image = "rancher/klipper-helm:v0.1.5" + image = "rancher/klipper-helm:v0.2.0" label = "helmcharts.helm.cattle.io/chart" name = "helm-controller" ) @@ -199,6 +199,22 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap) { Name: "VALUES_HASH", Value: hex.EncodeToString(valuesHash[:]), }, + { + Name: "HELM_DRIVER", + Value: "secret", + }, + { + Name: "CHART_NAMESPACE", + Value: chart.Namespace, + }, + { + Name: "CHART", + Value: chart.Spec.Chart, + }, + { + Name: "HELM_VERSION", + Value: chart.Spec.HelmVersion, + }, }, }, }, @@ -298,15 +314,12 @@ func args(chart *helmv1.HelmChart) []string { if chart.DeletionTimestamp != nil { return []string{ "delete", - "--purge", chart.Name, } } spec := chart.Spec args := []string{ "install", - "--name", chart.Name, - spec.Chart, } if spec.TargetNamespace != "" { args = append(args, "--namespace", spec.TargetNamespace) diff --git a/pkg/helm/controller_test.go b/pkg/helm/controller_test.go index 64428fc8..985c0d34 100644 --- a/pkg/helm/controller_test.go +++ b/pkg/helm/controller_test.go @@ -58,7 +58,7 @@ func TestDeleteJob(t *testing.T) { func TestInstallArgs(t *testing.T) { assert := assert.New(t) stringArgs := strings.Join(args(NewChart()), " ") - assert.Equal("install --name traefik stable/traefik --set-string rbac.enabled=true --set-string ssl.enabled=true", stringArgs) + assert.Equal("install --set-string rbac.enabled=true --set-string ssl.enabled=true", stringArgs) } func TestDeleteArgs(t *testing.T) { @@ -67,7 +67,7 @@ func TestDeleteArgs(t *testing.T) { deleteTime := v12.NewTime(time.Time{}) chart.DeletionTimestamp = &deleteTime stringArgs := strings.Join(args(chart), " ") - assert.Equal("delete --purge traefik", stringArgs) + assert.Equal("delete", stringArgs) } func NewChart() *v1.HelmChart {