Files
helmfile/test/integration/test-cases/issue-2297-local-chart-transformers.sh
T
yxxhero bbf925f154 test: add integration test for issue #1880 transformers with file:// deps (#2673)
* test: add integration test for issue #1880 transformers with file:// deps

Add an integration test reproducing the exact scenario from issue #1880:
a local chart with a relative file:// dependency (file://../library) used
together with kustomize transformers.

Before the fix (rewriteChartDependencies in PR #2334), chartify copied
the chart to a temp directory, breaking the relative file:// path and
causing helm dependency up to fail with:
  Error: directory /tmp/chartify.../monitoring/library not found

Also fix test artifact leak in issue923_test.go where OCI chart downloads
wrote to CWD because OutputDirTemplate lacked {{ .OutputDir }}.

Closes #1880

Signed-off-by: yxxhero <aiopsclub@163.com>

* fix(test): guard exit-code captures against set -e in integration tests

Under set -e (enabled in run.sh), a failing command exits the shell
before 'var=$?' can execute, defeating diagnostic cat+fail blocks and
breaking helm diff tests that expect exit code 2.

Replaced 'cmd; var=$?' with 'var=0; cmd || var=$?' across 12 test
files (29 sites), matching the pattern already used in oci-parallel-pull.sh.

Signed-off-by: yxxhero <aiopsclub@163.com>

---------

Signed-off-by: yxxhero <aiopsclub@163.com>
2026-06-29 08:49:51 +08:00

57 lines
1.9 KiB
Bash

# Integration test for issue #2297: Local chart + transformers causes panic
# https://github.com/helmfile/helmfile/issues/2297
#
# This test verifies that local charts with relative paths (like "../chart")
# work correctly when transformers are present. The bug manifests when there
# are MULTIPLE release files in helmfile.d and one uses local chart + transformers.
# Before the fix, chartify would try "helm pull ../chart" which fails because
# the path wasn't normalized.
issue_2297_input_dir="${cases_dir}/issue-2297-local-chart-transformers/input"
issue_2297_tmp=""
# Cleanup function for this test
cleanup_issue_2297() {
if [ -n "${issue_2297_tmp}" ] && [ -d "${issue_2297_tmp}" ]; then
rm -rf "${issue_2297_tmp}"
fi
}
trap cleanup_issue_2297 EXIT
issue_2297_tmp=$(mktemp -d)
# Convert helmfile to absolute path before cd (otherwise ./helmfile won't be found)
helmfile_real="$(pwd)/${helmfile}"
test_start "issue #2297: local chart with transformers"
info "Testing helmfile template with local chart and transformers"
# Run from the input directory where helmfile.d/ contains the helmfile with "../chart" reference
cd "${issue_2297_input_dir}"
# This should succeed - before the fix it would fail with:
# "helm pull ../chart --untar" fails with "repo .. not found"
result=0
${helmfile_real} template > "${issue_2297_tmp}/output.yaml" 2>&1 || result=$?
cd - > /dev/null
if [ $result -ne 0 ]; then
cat "${issue_2297_tmp}/output.yaml"
fail "helmfile template with local chart and transformers should not fail"
fi
# Verify the output contains the expected configmap with transformer annotation
if ! grep -q "test-annotation" "${issue_2297_tmp}/output.yaml"; then
cat "${issue_2297_tmp}/output.yaml"
fail "Output should contain the transformer annotation"
fi
info "Local chart with transformers works correctly"
# Cleanup and restore the original trap
cleanup_issue_2297
trap - EXIT
test_pass "issue #2297: local chart with transformers"