Skip to content

Commit

Permalink
Fix confusion of values and setValues
Browse files Browse the repository at this point in the history
  • Loading branch information
tete17 committed May 10, 2020
1 parent b61567b commit 2f28c54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand All @@ -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{
{
Expand All @@ -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",
Expand All @@ -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=<no value> --set image.tag=<no value> --set missing.key=<no value> --set other.key=<no value> --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=<no value> --set image.tag=<no value> --set missing.key=<no value> --set other.key=<no value> --set some.key=somevalue --kubeconfig kubeconfig"),
runContext: makeRunContext(testDeployConfigTemplated, false),
builds: []build.Artifact{
{
Expand All @@ -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{
{
Expand Down

0 comments on commit 2f28c54

Please sign in to comment.