From d059b28fb35e3ec827aed632d2511bf5d06265f4 Mon Sep 17 00:00:00 2001 From: Matthias Baur Date: Wed, 22 Jan 2025 13:42:33 +0100 Subject: [PATCH] Ensure 'helm repo add' is also not pollute on helmfile template (#1887) When having multiple helmfiles in one helmfile.d folder and multiple of them having repositories defined, the errors mention in #1749 still existed. Fixes #1749 (again) Signed-off-by: Matthias Baur --- pkg/app/app.go | 4 ++++ pkg/state/state.go | 4 ---- .../issue-1749/input/helmfile.d/helmfile1.yaml.gotmpl | 4 ++++ .../issue-1749/input/helmfile.d/helmfile2.yaml.gotmpl | 4 ++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index 61b4dce1..91beba57 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -240,6 +240,10 @@ func (a *App) Template(c TemplateConfigProvider) error { // Live output should never be enabled for the "template" subcommand to avoid breaking `helmfile template | kubectl apply -f -` run.helm.SetEnableLiveOutput(false) + // Reset helm extra args to not pollute BuildDeps() and AddRepo() on subsequent helmfiles + // https://github.com/helmfile/helmfile/issues/1749 + run.helm.SetExtraArgs() + prepErr := run.withPreparedCharts("template", state.ChartPrepareOptions{ SkipRepos: c.SkipRefresh() || c.SkipDeps(), SkipRefresh: c.SkipRefresh(), diff --git a/pkg/state/state.go b/pkg/state/state.go index e918933b..a28c05d9 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -1449,10 +1449,6 @@ func (st *HelmState) runHelmDepBuilds(helm helmexec.Interface, concurrency int, // // 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/test-cases/issue-1749/input/helmfile.d/helmfile1.yaml.gotmpl b/test/integration/test-cases/issue-1749/input/helmfile.d/helmfile1.yaml.gotmpl index e70221df..d2ec3c45 100644 --- 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 @@ -1,3 +1,7 @@ +repositories: +- name: bitnami + url: https://charts.bitnami.com/bitnami + releases: - name: test1 chart: ../../../../charts/raw 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 index 81f1cf1a..17e616e6 100644 --- 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 @@ -1,3 +1,7 @@ +repositories: +- name: prometheus-community + url: https://prometheus-community.github.io/helm-charts + releases: - name: test2 chart: ../../../../charts/raw