mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-08 06:12:09 +02:00
This commit adds comprehensive support for Helm 4 while maintaining full backward compatibility with Helm 3. The implementation includes: - Updated helm version detection to support both Helm 3 and Helm 4 - Added HELMFILE_HELM4 environment variable to control Helm version - Modified helm execution paths to handle version-specific binaries - Updated helm plugin installation to support split architecture - Helm 4: Uses split plugin architecture (3 separate .tgz files) - helm-secrets.tgz - helm-secrets-getter.tgz - helm-secrets-post-renderer.tgz - Helm 3: Continues using single plugin installation - Updated Dockerfiles, CI workflows, and core installation code - Helm 4 requires post-renderers to be plugins, not executable scripts - Created Helm plugin structure for integration tests - Updated helmfile.yaml templates to dynamically select renderer type - Added test plugins: add-cm, add-cm1, add-cm2 - Updated integration tests for Helm 3/4 compatibility - Created Helm 4 variant expected output files - Fixed test determinism issues (repo cleanup between iterations) - Added version-specific output filtering for warnings/messages - Updated workflows to test both Helm 3 and Helm 4 - Matrix testing across Helm versions - Updated helm-diff to v3.14.0 for compatibility - Updated README and docs with Helm 4 information - Added migration guidance - Updated version requirements All changes are backward compatible - existing Helm 3 users will see no behavior changes. fix: update Helm 4 lint expected output to match filtered output The grep filter removes the semver warning, so the expected output should not include it. Updated lint-helm4 files to match the filtered output (warning removed, no extra blank line). Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>
89 lines
4.8 KiB
Bash
89 lines
4.8 KiB
Bash
chart_need_case_input_dir="${cases_dir}/chart-needs/input"
|
|
chart_need_case_output_dir="${cases_dir}/chart-needs/output"
|
|
|
|
config_file="helmfile.yaml.gotmpl"
|
|
chart_needs_tmp=$(mktemp -d)
|
|
chart_needs_template_reverse=${chart_needs_tmp}/chart.needs.template.log
|
|
chart_needs_lint_reverse=${chart_needs_tmp}/chart.needs.lint.log
|
|
chart_needs_diff_reverse=${chart_needs_tmp}/chart.needs.diff.log
|
|
|
|
lint_out_file=${chart_need_case_output_dir}/lint
|
|
diff_out_file=${chart_need_case_output_dir}/diff
|
|
if [[ $EXTRA_HELMFILE_FLAGS == *--enable-live-output* ]]; then
|
|
lint_out_file=${chart_need_case_output_dir}/lint-live
|
|
diff_out_file=${chart_need_case_output_dir}/diff-live
|
|
fi
|
|
|
|
# Use Helm 4 variant files for lint (diff output is identical between Helm 3 and 4)
|
|
if [ "${HELMFILE_HELM4}" = "1" ]; then
|
|
if [ -f "${lint_out_file}-helm4" ]; then
|
|
lint_out_file="${lint_out_file}-helm4"
|
|
fi
|
|
fi
|
|
|
|
test_start "chart prepare when helmfile template with needs"
|
|
|
|
info "https://github.com/helmfile/helmfile/issues/455"
|
|
|
|
for i in $(seq 10); do
|
|
info "Comparing template/chart-needs #$i"
|
|
${helmfile} -f ${chart_need_case_input_dir}/${config_file} template --include-needs > ${chart_needs_template_reverse} || fail "\"helmfile template\" shouldn't fail"
|
|
./dyff between -bs ${chart_need_case_output_dir}/template ${chart_needs_template_reverse} || fail "\"helmfile template\" should be consistent"
|
|
done
|
|
|
|
for i in $(seq 10); do
|
|
info "Comparing lint/chart-needs #$i"
|
|
# Remove azuredisk-csi-driver repo to ensure consistent output (repo addition message)
|
|
${helm} repo remove azuredisk-csi-driver &>/dev/null || true
|
|
${helmfile} -f ${chart_need_case_input_dir}/${config_file} lint --include-needs | grep -v Linting | grep -v "has been removed" | grep -Ev "(Warning:.*is not a valid SemVerV2|\[WARNING\].*is not a valid SemVerV2|failed to load plugins)" > ${chart_needs_lint_reverse} || fail "\"helmfile lint\" shouldn't fail"
|
|
diff -u ${lint_out_file} ${chart_needs_lint_reverse} || fail "\"helmfile lint\" should be consistent"
|
|
done
|
|
|
|
for i in $(seq 10); do
|
|
info "Comparing diff/chart-needs #$i"
|
|
# Remove azuredisk-csi-driver repo to ensure consistent output (repo addition message)
|
|
${helm} repo remove azuredisk-csi-driver &>/dev/null || true
|
|
${helmfile} -f ${chart_need_case_input_dir}/${config_file} diff --include-needs | grep -Ev "Comparing release=azuredisk-csi-storageclass, chart=.*/chartify.*/azuredisk-csi-storageclass" > ${chart_needs_diff_reverse}.tmp || fail "\"helmfile diff\" shouldn't fail"
|
|
cat ${chart_needs_diff_reverse}.tmp | sed -E '/\*{20}/,/\*{20}/d' > ${chart_needs_diff_reverse}
|
|
|
|
# With --enable-live-output, there's a race condition that can cause non-deterministic ordering
|
|
# Try both the primary expected output and the alternate ordering
|
|
if ! diff -u ${diff_out_file} ${chart_needs_diff_reverse} >/dev/null 2>&1; then
|
|
if [[ $EXTRA_HELMFILE_FLAGS == *--enable-live-output* ]] && [ -f "${diff_out_file}-alt" ]; then
|
|
info "Primary diff failed, trying alternate ordering (due to --enable-live-output race condition)"
|
|
diff -u ${diff_out_file}-alt ${chart_needs_diff_reverse} || fail "\"helmfile diff\" should match either expected output"
|
|
else
|
|
diff -u ${diff_out_file} ${chart_needs_diff_reverse} || fail "\"helmfile diff\" should be consistent"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
info "Applying ${chart_need_case_input_dir}/${config_file}"
|
|
${helmfile} -f ${chart_need_case_input_dir}/${config_file} apply --include-needs
|
|
code=$?
|
|
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}"
|
|
|
|
${kubectl} get storageclass managed-csi -o yaml | grep -q "provisioner: disk.csi.azure.com" || fail "storageclass managed-csi should be created when applying helmfile.yaml"
|
|
|
|
info "Destroying ${chart_need_case_input_dir}/${config_file}"
|
|
${helmfile} -f ${chart_need_case_input_dir}/${config_file} destroy
|
|
code=$?
|
|
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile destroy: want 0, got ${code}"
|
|
|
|
info "Syncing ${chart_need_case_input_dir}/${config_file}"
|
|
${helmfile} -f ${chart_need_case_input_dir}/${config_file} sync --include-needs
|
|
code=$?
|
|
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}"
|
|
|
|
${kubectl} get storageclass managed-csi -o yaml | grep -q "provisioner: disk.csi.azure.com" || fail "storageclass managed-csi should be created when syncing helmfile.yaml"
|
|
|
|
info "Destroying ${chart_need_case_input_dir}/${config_file}"
|
|
${helmfile} -f ${chart_need_case_input_dir}/${config_file} destroy
|
|
code=$?
|
|
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile destroy: want 0, got ${code}"
|
|
|
|
# Clean up: remove azuredisk-csi-driver repo to avoid conflicts with subsequent tests
|
|
${helm} repo remove azuredisk-csi-driver &>/dev/null || true
|
|
|
|
test_pass "chart prepare when helmfile template with needs"
|