Skip to content

Commit

Permalink
Merge pull request #27 from galal-hussein/helmv3
Browse files Browse the repository at this point in the history
changes for helm v3
  • Loading branch information
ibuildthecloud authored Dec 18, 2019
2 parents f4e846c + 65c9a75 commit 1b1d396
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
1 change: 0 additions & 1 deletion pkg/apis/helm.cattle.io/v1/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apis/helm.cattle.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 17 additions & 4 deletions pkg/helm/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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,
},
},
},
},
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/helm/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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) {
Expand All @@ -41,7 +41,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 {
Expand Down

0 comments on commit 1b1d396

Please sign in to comment.