split yaml into individual docs

This commit is contained in:
2025-12-12 23:27:57 +05:30
parent d6e50190f6
commit 5db735d5be

View File

@@ -66,29 +66,30 @@ jobs:
for file in ${ALL_CHANGED_FILES}; do
[ -z "$file" ] && continue
echo "=== Validating: $file ==="
MANIFESTS=$(yq e -o=json '.[]' "$file" | jq -c 'select(.kind != null)')
for manifest in "${MANIFESTS[@]}"; do
KIND=$(echo $manifest | yq -r '.kind // ""')
# Split YAML into individual docs, output as JSON, and process each
yq e -o=json '. as $item ireduce ([]; . + [$item])' "$file" | \
jq -c '.[] | select(.kind != null)' | \
while read -r manifest; do
KIND=$(echo "$manifest" | jq -r '.kind // ""')
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 \
if ! echo "$manifest" | /kubeconform \
-schema-location "$SCHEMA_URL" \
-cache "$KUBECONFORM_CACHE_DIR" \
-output json \
"$manifest"; then
-; then
EXIT_CODE=1
fi
else
echo "Validating with default schemas"
if ! /kubeconform \
if ! echo "$manifest" | /kubeconform \
-schema-location default \
-cache "$KUBECONFORM_CACHE_DIR" \
-output json \
"$manifest"; then
-; then
EXIT_CODE=1
fi
fi