From 2f28c5452da6fffa456f7f93044dfffec18a2d97 Mon Sep 17 00:00:00 2001 From: Tete17 Date: Sun, 10 May 2020 14:37:20 +0200 Subject: [PATCH] Fix confusion of values and setValues --- pkg/skaffold/deploy/helm.go | 11 ++++++++--- pkg/skaffold/deploy/helm_test.go | 10 +++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index 4040056f581..f762e4ddf1f 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -256,11 +256,16 @@ func (h *HelmDeployer) Render(ctx context.Context, out io.Writer, builds []build args = append(args, "--set-string", value) } - for key, value := range r.Values { - args = append(args, "--set", fmt.Sprintf("%s=%s", key, value)) + sortedKeys := make([]string, 0, len(r.SetValues)) + for k := range r.SetValues { + sortedKeys = append(sortedKeys, k) + } + sort.Strings(sortedKeys) + for _, k := range sortedKeys { + args = append(args, "--set", fmt.Sprintf("%s=%s", k, r.SetValues[k])) } - sortedKeys := make([]string, 0, len(r.SetValueTemplates)) + sortedKeys = make([]string, 0, len(r.SetValueTemplates)) for k := range r.SetValueTemplates { sortedKeys = append(sortedKeys, k) } diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index 339745c1a4e..d9711790170 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -992,7 +992,7 @@ func TestHelmRender(t *testing.T) { shouldErr: false, commands: testutil. CmdRunWithOutput("helm version", version21). - AndRun("helm --kube-context kubecontext template examples/test --name skaffold-helm --set-string image=skaffold-helm:tag1 --set image=skaffold-helm --kubeconfig kubeconfig"), + AndRun("helm --kube-context kubecontext template examples/test --name skaffold-helm --set-string image=skaffold-helm:tag1 --set some.key=somevalue --kubeconfig kubeconfig"), runContext: makeRunContext(testDeployConfig, false), builds: []build.Artifact{ { @@ -1005,7 +1005,7 @@ func TestHelmRender(t *testing.T) { shouldErr: false, commands: testutil. CmdRunWithOutput("helm version", version31). - AndRun("helm --kube-context kubecontext template skaffold-helm examples/test --set-string image=skaffold-helm:tag1 --set image=skaffold-helm --kubeconfig kubeconfig"), + AndRun("helm --kube-context kubecontext template skaffold-helm examples/test --set-string image=skaffold-helm:tag1 --set some.key=somevalue --kubeconfig kubeconfig"), runContext: makeRunContext(testDeployConfig, false), builds: []build.Artifact{ { @@ -1018,7 +1018,7 @@ func TestHelmRender(t *testing.T) { shouldErr: false, commands: testutil. CmdRunWithOutput("helm version", version31). - AndRunWithOutput("helm --kube-context kubecontext template skaffold-helm examples/test --set-string image=skaffold-helm:tag1 --set image=skaffold-helm --kubeconfig kubeconfig", + AndRunWithOutput("helm --kube-context kubecontext template skaffold-helm examples/test --set-string image=skaffold-helm:tag1 --set some.key=somevalue --kubeconfig kubeconfig", "Dummy Output"), runContext: makeRunContext(testDeployConfig, false), outputFile: "dummy.yaml", @@ -1034,7 +1034,7 @@ func TestHelmRender(t *testing.T) { shouldErr: false, commands: testutil. CmdRunWithOutput("helm version", version31). - AndRun("helm --kube-context kubecontext template skaffold-helm examples/test --set-string image=skaffold-helm:tag1 --set image=skaffold-helm --set image.name= --set image.tag= --set missing.key= --set other.key= --set some.key=somevalue --kubeconfig kubeconfig"), + AndRun("helm --kube-context kubecontext template skaffold-helm examples/test --set-string image=skaffold-helm:tag1 --set image.name= --set image.tag= --set missing.key= --set other.key= --set some.key=somevalue --kubeconfig kubeconfig"), runContext: makeRunContext(testDeployConfigTemplated, false), builds: []build.Artifact{ { @@ -1046,7 +1046,7 @@ func TestHelmRender(t *testing.T) { description: "render with namespace", shouldErr: false, commands: testutil.CmdRunWithOutput("helm version", version31). - AndRun("helm --kube-context kubecontext template skaffold-helm examples/test --set-string image=skaffold-helm:tag1 --set image=skaffold-helm --namespace testNamespace --kubeconfig kubeconfig"), + AndRun("helm --kube-context kubecontext template skaffold-helm examples/test --set-string image=skaffold-helm:tag1 --set some.key=somevalue --namespace testNamespace --kubeconfig kubeconfig"), runContext: makeRunContext(testDeployNamespacedConfig, false), builds: []build.Artifact{ {