better handle multiple manifests in same file

This commit is contained in:
2025-12-12 22:59:55 +05:30
parent ed380aca40
commit c5b8c84a3c

View File

@@ -53,6 +53,7 @@ jobs:
["IPAddressPool"]="metallb.io/ipaddresspool_v1beta1.json" ["IPAddressPool"]="metallb.io/ipaddresspool_v1beta1.json"
["SealedSecret"]="bitnami.com/sealedsecret_v1alpha1.json" ["SealedSecret"]="bitnami.com/sealedsecret_v1alpha1.json"
["ClusterPolicy"]="nvidia.com/clusterpolicy_v1.json" ["ClusterPolicy"]="nvidia.com/clusterpolicy_v1.json"
["Plan"]="upgrade.cattle.io/plan_v1.json"
) )
EXIT_CODE=0 EXIT_CODE=0
@@ -62,7 +63,10 @@ jobs:
while IFS= read -r file; do while IFS= read -r file; do
[ -z "$file" ] && continue [ -z "$file" ] && continue
echo "=== Validating: $file ===" echo "=== Validating: $file ==="
KIND=$(yq -r '.kind // ""' "$file" 2>/dev/null || echo "") MANIFESTS=$(yq e '.[]' "$file" | jq -c 'select(.kind != null)')
for manifest in "${MANIFESTS[@]}"; do
KIND=$(echo $manifest | yq -r '.kind // ""')
if [[ -n "$KIND" && -n "${SCHEMA_MAP[$KIND]}" ]]; then if [[ -n "$KIND" && -n "${SCHEMA_MAP[$KIND]}" ]]; then
echo "Found $KIND - using custom schema" echo "Found $KIND - using custom schema"
@@ -72,7 +76,7 @@ jobs:
-schema-location "$SCHEMA_URL" \ -schema-location "$SCHEMA_URL" \
-cache "$KUBECONFORM_CACHE_DIR" \ -cache "$KUBECONFORM_CACHE_DIR" \
-output json \ -output json \
"$file"; then "$manifest"; then
EXIT_CODE=1 EXIT_CODE=1
fi fi
else else
@@ -81,10 +85,11 @@ jobs:
-schema-location default \ -schema-location default \
-cache "$KUBECONFORM_CACHE_DIR" \ -cache "$KUBECONFORM_CACHE_DIR" \
-output json \ -output json \
"$file"; then "$manifest"; then
EXIT_CODE=1 EXIT_CODE=1
fi fi
fi fi
done
echo "" echo ""
done <<< "${ALL_CHANGED_FILES}" done <<< "${ALL_CHANGED_FILES}"