split yaml into individual docs
This commit is contained in:
@@ -66,33 +66,34 @@ 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)')
|
||||
# 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 // ""')
|
||||
|
||||
for manifest in "${MANIFESTS[@]}"; do
|
||||
KIND=$(echo $manifest | yq -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 [[ -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 \
|
||||
"$manifest"; then
|
||||
EXIT_CODE=1
|
||||
if ! echo "$manifest" | /kubeconform \
|
||||
-schema-location "$SCHEMA_URL" \
|
||||
-cache "$KUBECONFORM_CACHE_DIR" \
|
||||
-output json \
|
||||
-; then
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
else
|
||||
echo "Validating with default schemas"
|
||||
if ! echo "$manifest" | /kubeconform \
|
||||
-schema-location default \
|
||||
-cache "$KUBECONFORM_CACHE_DIR" \
|
||||
-output json \
|
||||
-; then
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Validating with default schemas"
|
||||
if ! /kubeconform \
|
||||
-schema-location default \
|
||||
-cache "$KUBECONFORM_CACHE_DIR" \
|
||||
-output json \
|
||||
"$manifest"; then
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo ""
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user