diff --git a/test/integration/run.sh b/test/integration/run.sh index 9fb6ecac..14d4b435 100755 --- a/test/integration/run.sh +++ b/test/integration/run.sh @@ -115,6 +115,7 @@ ${kubectl} create namespace ${test_ns} || fail "Could not create namespace ${tes . ${dir}/test-cases/yaml-overwrite.sh . ${dir}/test-cases/chart-needs.sh . ${dir}/test-cases/postrender.sh +. ${dir}/test-cases/issue-2515.sh . ${dir}/test-cases/chartify.sh . ${dir}/test-cases/deps-mr-1011.sh . ${dir}/test-cases/deps-kustomization-i-1402.sh diff --git a/test/integration/test-cases/issue-2515.sh b/test/integration/test-cases/issue-2515.sh new file mode 100644 index 00000000..43c8ea7c --- /dev/null +++ b/test/integration/test-cases/issue-2515.sh @@ -0,0 +1,34 @@ +issue_2515_case_dir="${cases_dir}/issue-2515" +issue_2515_tmp=$(mktemp -d) + +if [ "${HELMFILE_HELM4}" = "1" ]; then + info "Skipping issue-2515 test for Helm 4 (post-renderer requires plugin)" + test_start "issue-2515 post-renderer with output-dir-template (skipped for Helm 4)" + test_pass "issue-2515 post-renderer with output-dir-template (skipped for Helm 4)" +else + test_start "issue-2515 post-renderer with output-dir-template" + info "Testing that --post-renderer output is written to files when --output-dir-template is set" + + issue_2515_output_dir="${issue_2515_tmp}/output" + + ${helmfile} -f ${issue_2515_case_dir}/input/helmfile.yaml \ + template \ + --post-renderer ${issue_2515_case_dir}/input/filter.bash \ + --output-dir-template "${issue_2515_output_dir}/{{.Release.Name}}" \ + &> ${issue_2515_tmp}/log || fail "helmfile template should not fail" + + issue_2515_output_file="${issue_2515_output_dir}/issue-2515/issue-2515.yaml" + if [ ! -f "${issue_2515_output_file}" ]; then + fail "Expected output file ${issue_2515_output_file} to exist" + fi + + if grep -q "original-cm" "${issue_2515_output_file}"; then + fail "Output should contain post-renderer output (Namespace), not original templates (original-cm). File contents: $(cat ${issue_2515_output_file})" + fi + + if ! grep -q "postrendered" "${issue_2515_output_file}"; then + fail "Output should contain post-renderer content (namespace postrendered). File contents: $(cat ${issue_2515_output_file})" + fi + + test_pass "issue-2515 post-renderer with output-dir-template" +fi diff --git a/test/integration/test-cases/issue-2515/input/filter.bash b/test/integration/test-cases/issue-2515/input/filter.bash new file mode 100755 index 00000000..b069f429 --- /dev/null +++ b/test/integration/test-cases/issue-2515/input/filter.bash @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +printf -- "---\napiVersion: v1\nkind: Namespace\nmetadata:\n name: postrendered\n" diff --git a/test/integration/test-cases/issue-2515/input/helmfile.yaml b/test/integration/test-cases/issue-2515/input/helmfile.yaml new file mode 100644 index 00000000..6355b21f --- /dev/null +++ b/test/integration/test-cases/issue-2515/input/helmfile.yaml @@ -0,0 +1,13 @@ +releases: +- name: issue-2515 + chart: ../../charts/raw + values: + - templates: + - | + apiVersion: v1 + kind: ConfigMap + metadata: + name: original-cm + namespace: {{ .Release.Namespace }} + data: + key: value