split yaml into individual docs
This commit is contained in:
@@ -66,33 +66,34 @@ jobs:
|
|||||||
for file in ${ALL_CHANGED_FILES}; do
|
for file in ${ALL_CHANGED_FILES}; do
|
||||||
[ -z "$file" ] && continue
|
[ -z "$file" ] && continue
|
||||||
echo "=== Validating: $file ==="
|
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
|
if [[ -n "$KIND" && -n "${SCHEMA_MAP[$KIND]}" ]]; then
|
||||||
KIND=$(echo $manifest | yq -r '.kind // ""')
|
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
|
if ! echo "$manifest" | /kubeconform \
|
||||||
echo "Found $KIND - using custom schema"
|
-schema-location "$SCHEMA_URL" \
|
||||||
SCHEMA_URL="https://raw.githubusercontent.com/datreeio/CRDs-catalog/refs/heads/main/${SCHEMA_MAP[$KIND]}"
|
-cache "$KUBECONFORM_CACHE_DIR" \
|
||||||
|
-output json \
|
||||||
if ! /kubeconform \
|
-; then
|
||||||
-schema-location "$SCHEMA_URL" \
|
EXIT_CODE=1
|
||||||
-cache "$KUBECONFORM_CACHE_DIR" \
|
fi
|
||||||
-output json \
|
else
|
||||||
"$manifest"; then
|
echo "Validating with default schemas"
|
||||||
EXIT_CODE=1
|
if ! echo "$manifest" | /kubeconform \
|
||||||
|
-schema-location default \
|
||||||
|
-cache "$KUBECONFORM_CACHE_DIR" \
|
||||||
|
-output json \
|
||||||
|
-; 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 \
|
|
||||||
"$manifest"; then
|
|
||||||
EXIT_CODE=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user