fix: skip helm repo update when only OCI repos are configured (#2420)

When using only OCI repositories, helmfile would attempt to run
'helm repo update' which fails with 'no repositories found' error.
OCI repositories don't need 'helm repo update' as they use
'helm registry login' instead.

This fix adds a HasNonOCIRepositories() helper function and uses it
to determine whether to run 'helm repo update'.

Fixes #2418

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2026-02-25 12:13:20 +08:00
committed by GitHub
parent 04299856ef
commit 27c78a123e
8 changed files with 150 additions and 13 deletions
+1
View File
@@ -132,6 +132,7 @@ ${kubectl} create namespace ${test_ns} || fail "Could not create namespace ${tes
. ${dir}/test-cases/unittest.sh
. ${dir}/test-cases/issue-2409-sequential-kubecontext.sh
. ${dir}/test-cases/issue-2269.sh
. ${dir}/test-cases/issue-2418.sh
# ALL DONE -----------------------------------------------------------------------------------------------------------
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Test for issue #2418: Skip helm repo update when only OCI repos are configured
# When using only OCI repositories combined with a local chart, helmfile should NOT
# attempt to run `helm repo update` which would fail with "no repositories found".
issue_2418_input_dir="${cases_dir}/issue-2418/input"
issue_2418_tmp=$(mktemp -d)
issue_2418_output="${issue_2418_tmp}/template.log"
cleanup_issue_2418() {
rm -rf "${issue_2418_tmp}"
}
trap cleanup_issue_2418 EXIT
test_start "issue-2418: OCI repos + local chart should skip helm repo update"
# Run helmfile template - this would fail with "no repositories found" before the fix
# because it would attempt to run `helm repo update` for OCI repos
info "Running helmfile template with OCI repo + local chart"
${helmfile} -f "${issue_2418_input_dir}/helmfile.yaml" template > "${issue_2418_output}" 2>&1 || {
code=$?
cat "${issue_2418_output}"
# Check if the failure is due to "no repositories found" error
if grep -q "no repositories found" "${issue_2418_output}"; then
fail "Issue #2418 regression: helm repo update was called for OCI-only repos"
fi
fail "helmfile template failed with exit code ${code}"
}
info "SUCCESS: helmfile template completed without 'no repositories found' error"
info "Template output:"
cat "${issue_2418_output}"
trap - EXIT
test_pass "issue-2418: OCI repos + local chart should skip helm repo update"
@@ -0,0 +1,6 @@
apiVersion: v2
name: customresources
description: A Helm chart for custom resources
type: application
version: 0.1.0
appVersion: "1.0"
@@ -0,0 +1 @@
{{- /* Empty templates */ -}}
@@ -0,0 +1 @@
# Default values for customresources.
@@ -0,0 +1,9 @@
repositories:
- name: karpenter
url: public.ecr.aws/karpenter
oci: true
releases:
- name: custom-resources
chart: ./customresources
namespace: default