mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-18 20:12:13 +02:00
* test: add integration test for issue #2291 with all fixes Add comprehensive integration test for issue #2291 that validates CRD preservation when using strategicMergePatches with chartify. Problem: When using strategicMergePatches, chartify was relocating CRDs from templates/crds/ to root crds/ directory, changing how Helm manages them. This caused helm diff to incorrectly show CRDs as being removed, even though they were still present. Solution: Chartify now preserves the original CRD location in templates/crds/. This integration test validates the fix by: 1. Templating a chart with CRDs in templates/crds/ 2. Applying the chart with strategicMergePatches 3. Verifying CRD is installed 4. Running helm diff to ensure CRD is NOT marked for removal 5. Verifying the strategic merge patch was applied Additional fixes included in this commit: - Fixed grep command error when matching YAML deletion patterns - Updated expected test output for Helm 4 diff behavior - Fixed EXIT trap interference between test cases - Added --plain-http flag for Helm 4 OCI registry compatibility - Ensured CRD templates are valid (cluster-scoped, no namespace) - Fixed strategic merge patch namespace matching Test coverage: - CRD preservation in templates/crds/ subdirectory - Strategic merge patch application - Helm diff behavior with CRDs - Integration with chartify kustomize processing Fixes #2291 Signed-off-by: Aditya Menon <amenon@canarytechnologies.com> * switch chartify package to upstream one Signed-off-by: Aditya Menon <amenon@canarytechnologies.com> * implement copilot suggestion Signed-off-by: Aditya Menon <amenon@canarytechnologies.com> --------- Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>
This commit is contained in:
@@ -65,6 +65,7 @@ info "SUCCESS: OCI charts without version do not trigger validation error"
|
||||
if ! command -v docker &> /dev/null; then
|
||||
info "Skipping registry tests (Docker not available)"
|
||||
rm -rf "${issue_2247_tmp_dir}"
|
||||
trap - EXIT
|
||||
test_pass "issue-2247: OCI charts without version (validation tests only)"
|
||||
return 0
|
||||
fi
|
||||
@@ -73,6 +74,7 @@ fi
|
||||
if ! docker info &> /dev/null; then
|
||||
info "Skipping registry tests (Docker daemon not running)"
|
||||
rm -rf "${issue_2247_tmp_dir}"
|
||||
trap - EXIT
|
||||
test_pass "issue-2247: OCI charts without version (validation tests only)"
|
||||
return 0
|
||||
fi
|
||||
@@ -105,6 +107,7 @@ if [ $? -ne 0 ]; then
|
||||
cat "${issue_2247_tmp_dir}/registry-start.log"
|
||||
warn "Failed to start Docker registry - skipping registry tests"
|
||||
rm -rf "${issue_2247_tmp_dir}"
|
||||
trap - EXIT
|
||||
test_pass "issue-2247: OCI charts without version (validation tests only)"
|
||||
return 0
|
||||
fi
|
||||
@@ -125,6 +128,7 @@ done
|
||||
if [ $attempt -eq $max_attempts ]; then
|
||||
warn "Registry did not become ready in time - skipping registry tests"
|
||||
cleanup_registry
|
||||
trap - EXIT
|
||||
test_pass "issue-2247: OCI charts without version (validation tests only)"
|
||||
return 0
|
||||
fi
|
||||
@@ -138,6 +142,7 @@ if [ $? -ne 0 ]; then
|
||||
cat "${issue_2247_tmp_dir}/package.log"
|
||||
warn "Failed to package chart - skipping registry tests"
|
||||
cleanup_registry
|
||||
trap - EXIT
|
||||
test_pass "issue-2247: OCI charts without version (validation tests only)"
|
||||
return 0
|
||||
fi
|
||||
@@ -145,12 +150,14 @@ set -e # Re-enable exit on error after successful package
|
||||
|
||||
info "Pushing chart version 1.0.0 to local registry"
|
||||
set +e # Disable exit on error to handle failures gracefully
|
||||
${helm} push "${issue_2247_tmp_dir}/test-chart-2247-1.0.0.tgz" oci://localhost:${registry_port} > "${issue_2247_tmp_dir}/push.log" 2>&1
|
||||
# Use --plain-http for localhost registry (HTTP instead of HTTPS)
|
||||
${helm} push "${issue_2247_tmp_dir}/test-chart-2247-1.0.0.tgz" oci://localhost:${registry_port} --plain-http > "${issue_2247_tmp_dir}/push.log" 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
set -e # Re-enable before cleanup
|
||||
cat "${issue_2247_tmp_dir}/push.log"
|
||||
warn "Failed to push chart to registry - skipping registry tests"
|
||||
cleanup_registry
|
||||
trap - EXIT
|
||||
test_pass "issue-2247: OCI charts without version (validation tests only)"
|
||||
return 0
|
||||
fi
|
||||
@@ -162,7 +169,7 @@ cp -r "${issue_2247_chart_dir}" "${issue_2247_tmp_dir}/chart-v2"
|
||||
sed -i.bak 's/version: 1.0.0/version: 2.0.0/' "${issue_2247_tmp_dir}/chart-v2/Chart.yaml"
|
||||
set +e # Disable exit on error for package/push operations
|
||||
${helm} package "${issue_2247_tmp_dir}/chart-v2" -d "${issue_2247_tmp_dir}" > "${issue_2247_tmp_dir}/package-v2.log" 2>&1
|
||||
${helm} push "${issue_2247_tmp_dir}/test-chart-2247-2.0.0.tgz" oci://localhost:${registry_port} > "${issue_2247_tmp_dir}/push-v2.log" 2>&1
|
||||
${helm} push "${issue_2247_tmp_dir}/test-chart-2247-2.0.0.tgz" oci://localhost:${registry_port} --plain-http > "${issue_2247_tmp_dir}/push-v2.log" 2>&1
|
||||
set -e # Re-enable exit on error
|
||||
|
||||
info "Successfully pushed chart versions 1.0.0 and 2.0.0"
|
||||
@@ -270,4 +277,6 @@ else
|
||||
fi
|
||||
|
||||
# All tests passed!
|
||||
# Remove the EXIT trap to avoid interfering with subsequent tests
|
||||
trap - EXIT
|
||||
test_pass "issue-2247: OCI charts without version (all tests including registry)"
|
||||
|
||||
Reference in New Issue
Block a user