kubeconform workflow will handle multiple manifests in a single file #204

Closed
aggarwalakshun wants to merge 5 commits from better-handle-multiple-manifests-in-same-file into main
Showing only changes of commit 47ca323b3c - Show all commits

View File

@@ -62,29 +62,33 @@ jobs:
while IFS= read -r file; do
[ -z "$file" ] && continue
echo "=== Validating: $file ==="
KIND=$(yq -r '.kind // ""' "$file" 2>/dev/null || echo "")
MANIFESTS=$(yq r $file --tojson | jq '.[]' | jq -c 'select(.kind != null)')
if [[ -n "$KIND" && -n "${SCHEMA_MAP[$KIND]}" ]]; then
echo "Found $KIND - using custom schema"
SCHEMA_URL="https://raw.githubusercontent.com/datreeio/CRDs-catalog/refs/heads/main/${SCHEMA_MAP[$KIND]}"
for manifest in ${MANIFESTS}; do
KIND=$(echo $manifest | yq -r '.kind // ""')
if ! /kubeconform \
-schema-location "$SCHEMA_URL" \
-cache "$KUBECONFORM_CACHE_DIR" \
-output json \
"$file"; then
EXIT_CODE=1
if [[ -n "$KIND" && -n "${SCHEMA_MAP[$KIND]}" ]]; then
echo "Found $KIND - using custom schema"
SCHEMA_URL="https://raw.githubusercontent.com/datreeio/CRDs-catalog/refs/heads/main/${SCHEMA_MAP[$KIND]}"
if ! /kubeconform \
-schema-location "$SCHEMA_URL" \
-cache "$KUBECONFORM_CACHE_DIR" \
-output json \
"<(echo '$manifest')"; then
EXIT_CODE=1
fi
else
echo "Validating with default schemas"
if ! /kubeconform \
-schema-location default \
-cache "$KUBECONFORM_CACHE_DIR" \
-output json \
"<(echo '$manifest')"; then
EXIT_CODE=1
fi
fi
else
echo "Validating with default schemas"
if ! /kubeconform \
-schema-location default \
-cache "$KUBECONFORM_CACHE_DIR" \
-output json \
"$file"; then
EXIT_CODE=1
fi
fi
done
echo ""
done <<< "${ALL_CHANGED_FILES}"