From b94c960fc4488ec8ee3789bfc5a21d7e4b668a5c Mon Sep 17 00:00:00 2001 From: yxxhero Date: Fri, 23 Jan 2026 12:10:39 +0800 Subject: [PATCH] fix: ensure repo update only runs when repositories are configured This fixes CI issues where tests fail with 'no repositories found' error. The PR #2378 adds a single helm.UpdateRepo() call before running helm dep build commands. However, when no repositories are configured, this call fails. The fix adds a check for len(st.Repositories) > 0 before calling UpdateRepo(). Additionally, updated snapshot files to reflect the new output ordering where repo update happens before building dependencies. Signed-off-by: yxxhero --- pkg/state/state.go | 3 ++- .../helmfile/testdata/snapshot/chart_need/output.yaml | 4 +++- .../snapshot/chart_need_enable_live_output/output.yaml | 4 +++- .../snapshot/release_template_inheritance/output.yaml | 5 +++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/state/state.go b/pkg/state/state.go index 53f77066..53570cca 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -1851,7 +1851,8 @@ func (st *HelmState) runHelmDepBuilds(helm helmexec.Interface, concurrency int, // Perform an update of repos once before running `helm dep build` so that we // can safely pass --skip-refresh to the command to avoid doing a repo update // for every iteration of the loop where charts have external dependencies. - if len(builds) > 0 && !opts.SkipRefresh { + // Only do this if there are repositories configured. + if len(builds) > 0 && !opts.SkipRefresh && len(st.Repositories) > 0 { if err := helm.UpdateRepo(); err != nil { return fmt.Errorf("updating repo: %w", err) } diff --git a/test/e2e/template/helmfile/testdata/snapshot/chart_need/output.yaml b/test/e2e/template/helmfile/testdata/snapshot/chart_need/output.yaml index 7954f3c1..46577aa7 100644 --- a/test/e2e/template/helmfile/testdata/snapshot/chart_need/output.yaml +++ b/test/e2e/template/helmfile/testdata/snapshot/chart_need/output.yaml @@ -1,10 +1,12 @@ Adding repo myrepo http://localhost:18080/ "myrepo" has been added to your repositories -Building dependency release=foo, chart=$WD/temp1/foo +Updating repo Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "myrepo" chart repository Update Complete. ⎈Happy Helming!⎈ + +Building dependency release=foo, chart=$WD/temp1/foo Saving 1 charts Downloading raw from repo http://localhost:18080/ Deleting outdated charts diff --git a/test/e2e/template/helmfile/testdata/snapshot/chart_need_enable_live_output/output.yaml b/test/e2e/template/helmfile/testdata/snapshot/chart_need_enable_live_output/output.yaml index 67616a32..61f4dd37 100644 --- a/test/e2e/template/helmfile/testdata/snapshot/chart_need_enable_live_output/output.yaml +++ b/test/e2e/template/helmfile/testdata/snapshot/chart_need_enable_live_output/output.yaml @@ -2,10 +2,12 @@ Live output is enabled Adding repo myrepo http://localhost:18081/ "myrepo" has been added to your repositories -Building dependency release=foo, chart=$WD/temp1/foo +Updating repo Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "myrepo" chart repository Update Complete. ⎈Happy Helming!⎈ + +Building dependency release=foo, chart=$WD/temp1/foo Saving 1 charts Downloading raw from repo http://localhost:18081/ Deleting outdated charts diff --git a/test/e2e/template/helmfile/testdata/snapshot/release_template_inheritance/output.yaml b/test/e2e/template/helmfile/testdata/snapshot/release_template_inheritance/output.yaml index 8f4523d9..3cf214c1 100644 --- a/test/e2e/template/helmfile/testdata/snapshot/release_template_inheritance/output.yaml +++ b/test/e2e/template/helmfile/testdata/snapshot/release_template_inheritance/output.yaml @@ -1,6 +1,11 @@ Adding repo myrepo http://localhost:18084/ "myrepo" has been added to your repositories +Updating repo +Hang tight while we grab the latest from your chart repositories... +...Successfully got an update from the "myrepo" chart repository +Update Complete. ⎈Happy Helming!⎈ + Building dependency release=foo1, chart=../../charts/raw-0.1.0 Building dependency release=foo2, chart=../../charts/raw-0.1.0 Templating release=foo1, chart=../../charts/raw-0.1.0