Skip to content

Commit c3caac3

Browse files
refactor helm functions - fix install and tests
1 parent 4779d97 commit c3caac3

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

pkg/addons/helm.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,24 @@ import (
2929
func installHelmChart (ctx context.Context, chart *assets.HelmChart) *exec.Cmd {
3030
args := []string{
3131
fmt.Sprintf("KUBECONFIG=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")),
32-
"helm", "uninstall", chart.Name,
33-
}
32+
"helm", "upgrade", "--install", chart.Name, chart.Repo, "--create-namespace",
33+
}
3434
if chart.Namespace != "" {
3535
args = append(args, "--namespace", chart.Namespace)
3636
}
37+
38+
if chart.Values != nil {
39+
for _, value := range chart.Values {
40+
args = append(args, "--set", value)
41+
}
42+
}
43+
44+
if chart.ValueFiles != nil {
45+
for _, value := range chart.ValueFiles {
46+
args = append(args, "--values", value)
47+
}
48+
}
49+
3750
return exec.CommandContext(ctx, "sudo", args...)
3851
}
3952

pkg/addons/helm_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestHelmCommand(t *testing.T) {
6666

6767
for _, test := range tests {
6868
t.Run(test.description, func(t *testing.T) {
69-
command := helmCommand(context.Background(), test.chart, test.enable )
69+
command := helmUninstallOrInstall(context.Background(), test.chart, test.enable )
7070
actual := strings.Join(command.Args, " ")
7171
if actual != test.expected {
7272
t.Errorf("helm command mismatch:\nexpected: %s\nactual: %s", test.expected, actual)

0 commit comments

Comments
 (0)