kubeconform workflow will handle multiple manifests in a single file
All checks were successful
Validate Kubernetes Manifests / kubeconform (pull_request) Successful in 24s

This commit is contained in:
2025-12-12 22:47:40 +05:30
parent ed380aca40
commit 47ca323b3c

View File

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