diff --git a/pkg/helmexec/exec.go b/pkg/helmexec/exec.go index 1352d7ae..283910ef 100644 --- a/pkg/helmexec/exec.go +++ b/pkg/helmexec/exec.go @@ -597,10 +597,6 @@ func (helm *execer) exec(args []string, env map[string]string, overrideEnableLiv enableLiveOutput = *overrideEnableLiveOutput } outBytes, err := helm.runner.Execute(helm.helmBinary, cmdargs, env, enableLiveOutput) - - // Reset extra args after each helm execution - helm.SetExtraArgs() - return outBytes, err } @@ -618,10 +614,6 @@ func (helm *execer) execStdIn(args []string, env map[string]string, stdin io.Rea cmd := fmt.Sprintf("exec: %s %s", helm.helmBinary, strings.Join(cmdargs, " ")) helm.logger.Debug(cmd) outBytes, err := helm.runner.ExecuteStdIn(helm.helmBinary, cmdargs, env, stdin) - - // Reset extra args after each helm execution - helm.SetExtraArgs() - return outBytes, err } diff --git a/pkg/state/state.go b/pkg/state/state.go index 717ed80d..1514d931 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -1439,6 +1439,11 @@ func (st *HelmState) runHelmDepBuilds(helm helmexec.Interface, concurrency int, // So we shouldn't use goroutines like we do for other helm operations here. // // See https://github.com/roboll/helmfile/issues/1521 + + // Reset helm extra args to not pollute BuildDeps() on subsequent helmfiles + // https://github.com/helmfile/helmfile/issues/1749 + helm.SetExtraArgs() + for _, r := range builds { buildDepsFlags := getBuildDepsFlags(r) if err := helm.BuildDeps(r.releaseName, r.chartPath, buildDepsFlags...); err != nil { diff --git a/test/integration/run.sh b/test/integration/run.sh index 1b163a31..faedd4b4 100755 --- a/test/integration/run.sh +++ b/test/integration/run.sh @@ -69,6 +69,7 @@ function cleanup() { set -e trap cleanup EXIT info "Using namespace: ${test_ns}" +info "Using Helm version:" $(${helm} version --short | grep -o 'v[0-9.]\+') ${helm} plugin ls | grep diff || ${helm} plugin install https://github.com/databus23/helm-diff --version v${HELM_DIFF_VERSION} info "Using Kustomize version: $(kustomize version --short | grep -o 'v[0-9.]\+')" ${kubectl} get namespace ${test_ns} &> /dev/null && warn "Namespace ${test_ns} exists, from a previous test run?" @@ -96,6 +97,7 @@ ${kubectl} create namespace ${test_ns} || fail "Could not create namespace ${tes . ${dir}/test-cases/deps-mr-1011.sh . ${dir}/test-cases/deps-kustomization-i-1402.sh . ${dir}/test-cases/hcl-secrets.sh +. ${dir}/test-cases/issue-1749.sh # ALL DONE ----------------------------------------------------------------------------------------------------------- diff --git a/test/integration/test-cases/issue-1749.sh b/test/integration/test-cases/issue-1749.sh new file mode 100644 index 00000000..22344957 --- /dev/null +++ b/test/integration/test-cases/issue-1749.sh @@ -0,0 +1,12 @@ +issue_1749_input_dir="${cases_dir}/issue-1749/input" +helmfile_real="$(pwd)/${helmfile}" + +test_start "issue 1749 helmfile.d template --args --dry-run=server" +cd "${issue_1749_input_dir}" +${helmfile_real} template --args --dry-run=server || fail "\"issue 1749 helmfile.d template --args --dry-run=server\" shouldn't fail" +cd - +test_pass "issue 1749 helmfile.d template --args --dry-run=server" + +test_start "issue 1749 helmfile.yaml template --args --dry-run=server" +${helmfile_real} template -f "${issue_1749_input_dir}/helmfile-2in1.yaml.gotmpl" --args --dry-run=server || fail "\"issue 1749 helmfile.yaml template --args --dry-run=server\" shouldn't fail" +test_pass "issue 1749 helmfile.yaml template --args --dry-run=server" diff --git a/test/integration/test-cases/issue-1749/input/helmfile-2in1.yaml.gotmpl b/test/integration/test-cases/issue-1749/input/helmfile-2in1.yaml.gotmpl new file mode 100644 index 00000000..6f699a06 --- /dev/null +++ b/test/integration/test-cases/issue-1749/input/helmfile-2in1.yaml.gotmpl @@ -0,0 +1,23 @@ +releases: + - name: test1 + chart: ../../../charts/raw + values: + - templates: + - | + apiVersion: v1 + kind: ConfigMap + metadata: + name: {{`{{ .Release.Name }}`}} + data: + foo: {{`{{ (first (lookup "v1" "Namespace" "" "").items).metadata.name }}`}} + - name: test2 + chart: ../../../charts/raw + values: + - templates: + - | + apiVersion: v1 + kind: ConfigMap + metadata: + name: {{`{{ .Release.Name }}`}} + data: + foo: {{`{{ (first (lookup "v1" "Namespace" "" "").items).metadata.name }}`}} diff --git a/test/integration/test-cases/issue-1749/input/helmfile.d/helmfile1.yaml.gotmpl b/test/integration/test-cases/issue-1749/input/helmfile.d/helmfile1.yaml.gotmpl new file mode 100644 index 00000000..e70221df --- /dev/null +++ b/test/integration/test-cases/issue-1749/input/helmfile.d/helmfile1.yaml.gotmpl @@ -0,0 +1,12 @@ +releases: + - name: test1 + chart: ../../../../charts/raw + values: + - templates: + - | + apiVersion: v1 + kind: ConfigMap + metadata: + name: {{`{{ .Release.Name }}`}} + data: + foo: {{`{{ (first (lookup "v1" "Namespace" "" "").items).metadata.name }}`}} diff --git a/test/integration/test-cases/issue-1749/input/helmfile.d/helmfile2.yaml.gotmpl b/test/integration/test-cases/issue-1749/input/helmfile.d/helmfile2.yaml.gotmpl new file mode 100644 index 00000000..81f1cf1a --- /dev/null +++ b/test/integration/test-cases/issue-1749/input/helmfile.d/helmfile2.yaml.gotmpl @@ -0,0 +1,12 @@ +releases: + - name: test2 + chart: ../../../../charts/raw + values: + - templates: + - | + apiVersion: v1 + kind: ConfigMap + metadata: + name: {{`{{ .Release.Name }}`}} + data: + foo: {{`{{ (first (lookup "v1" "Namespace" "" "").items).metadata.name }}`}}