diff --git a/test/integration/test-cases/issue-2515.sh b/test/integration/test-cases/issue-2515.sh index a8040147..86660ef8 100644 --- a/test/integration/test-cases/issue-2515.sh +++ b/test/integration/test-cases/issue-2515.sh @@ -24,14 +24,27 @@ ${helmfile} -f ${issue_2515_case_dir}/input/helmfile.yaml \ --output-dir-template "${issue_2515_output_dir}/{{.Release.Name}}" \ &> ${issue_2515_tmp}/log || fail "helmfile template should not fail" -issue_2515_templates_dir="${issue_2515_output_dir}/issue-2515/templates" -if [ ! -d "${issue_2515_templates_dir}" ]; then - fail "Expected templates directory ${issue_2515_templates_dir} to exist" -fi - -issue_2515_output_file=$(find "${issue_2515_templates_dir}" -type f \( -name '*.yaml' -o -name '*.yml' \) | head -n 1) -if [ -z "${issue_2515_output_file}" ]; then - fail "Expected rendered YAML file under ${issue_2515_templates_dir}" +if [ "${HELMFILE_HELM4}" = "1" ]; then + # Helm 4 natively applies --post-renderer to --output-dir output. + # The directory structure may differ from Helm 3 (no guaranteed templates/ subdir), + # so search recursively for any YAML file. Fall back to stdout (log) if no files written. + issue_2515_output_file=$(find "${issue_2515_output_dir}" -type f \( -name '*.yaml' -o -name '*.yml' \) 2>/dev/null | head -n 1) + if [ -z "${issue_2515_output_file}" ]; then + # Helm 4 may write post-rendered output to stdout rather than files + issue_2515_output_file="${issue_2515_tmp}/log" + if ! grep -q "postrendered" "${issue_2515_output_file}"; then + fail "Expected post-rendered YAML (namespace postrendered) in output files under ${issue_2515_output_dir} or stdout. Dir: $(find ${issue_2515_output_dir} 2>/dev/null || echo 'not found'). Log: $(cat ${issue_2515_output_file})" + fi + fi +else + issue_2515_templates_dir="${issue_2515_output_dir}/issue-2515/templates" + if [ ! -d "${issue_2515_templates_dir}" ]; then + fail "Expected templates directory ${issue_2515_templates_dir} to exist" + fi + issue_2515_output_file=$(find "${issue_2515_templates_dir}" -type f \( -name '*.yaml' -o -name '*.yml' \) | head -n 1) + if [ -z "${issue_2515_output_file}" ]; then + fail "Expected rendered YAML file under ${issue_2515_templates_dir}" + fi fi if grep -q "original-cm" "${issue_2515_output_file}"; then