feat: add Helm 4 post-renderer plugin and enable Helm 4 issue-2515 integration test
Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/3da2949c-a9d6-4e16-9b4a-a7e241080089 Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
This commit is contained in:
parent
14a40eb23f
commit
e2dcdea56a
|
|
@ -1,39 +1,49 @@
|
|||
issue_2515_case_dir="$(cd "${cases_dir}/issue-2515" && pwd)"
|
||||
issue_2515_tmp=$(mktemp -d)
|
||||
|
||||
# Determine the post-renderer argument.
|
||||
# Helm 3 accepts an executable script; Helm 4 requires a plugin name.
|
||||
if [ "${HELMFILE_HELM4}" = "1" ]; then
|
||||
info "Skipping issue-2515 test for Helm 4 (Helm 4 natively applies --post-renderer to --output-dir output)"
|
||||
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)"
|
||||
test_start "issue-2515 post-renderer with output-dir-template (Helm 4)"
|
||||
info "Installing filter post-renderer plugin for Helm 4"
|
||||
${helm} plugin uninstall filter &>/dev/null || true
|
||||
${helm} plugin install ${issue_2515_case_dir}/input/helm-plugin-filter ${PLUGIN_INSTALL_FLAGS} || fail "Failed to install filter plugin"
|
||||
issue_2515_postrenderer_arg="filter"
|
||||
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_postrenderer_arg="${issue_2515_case_dir}/input/filter.bash"
|
||||
fi
|
||||
|
||||
issue_2515_output_dir="${issue_2515_tmp}/output"
|
||||
info "Testing that --post-renderer output is written to files when --output-dir-template is set"
|
||||
|
||||
${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_dir="${issue_2515_tmp}/output"
|
||||
|
||||
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
|
||||
${helmfile} -f ${issue_2515_case_dir}/input/helmfile.yaml \
|
||||
template \
|
||||
--post-renderer ${issue_2515_postrenderer_arg} \
|
||||
--output-dir-template "${issue_2515_output_dir}/{{.Release.Name}}" \
|
||||
&> ${issue_2515_tmp}/log || fail "helmfile template should not fail"
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
if [ "${HELMFILE_HELM4}" = "1" ]; then
|
||||
test_pass "issue-2515 post-renderer with output-dir-template (Helm 4)"
|
||||
else
|
||||
test_pass "issue-2515 post-renderer with output-dir-template"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# Discard stdin (pre-rendered content) and output a fixed Namespace resource.
|
||||
# This verifies that the post-renderer output — not the original templates — is
|
||||
# written to the output directory.
|
||||
cat > /dev/null
|
||||
printf -- "---\napiVersion: v1\nkind: Namespace\nmetadata:\n name: postrendered\n"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v1
|
||||
type: postrenderer/v1
|
||||
name: filter
|
||||
version: 0.1.0
|
||||
runtime: subprocess
|
||||
runtimeConfig:
|
||||
platformCommand:
|
||||
- command: ${HELM_PLUGIN_DIR}/filter.sh
|
||||
Loading…
Reference in New Issue