Test order values by sections

This commit is contained in:
dvirlabs 2025-06-22 22:43:50 +03:00
parent 13b25ac71d
commit 244b069b31

View File

@ -50,7 +50,6 @@ echo "🔁 Merging new entries into: $ORIGINAL_FILE"
TEMP_FILE=$(mktemp)
cp "$ORIGINAL_FILE" "$TEMP_FILE"
# Strip namespace key from existing values if present
yq eval -o=json '.cloudflare.ingress' "$TEMP_FILE" > /tmp/existing.json
yq eval '.ingress' "$GENERATED_FILE" | yq -o=json | jq -c '.[]' | while read -r new_entry; do
@ -68,14 +67,12 @@ yq eval '.ingress' "$GENERATED_FILE" | yq -o=json | jq -c '.[]' | while read -r
fi
done
# === 🧹 Group and sort with comments ===
echo "🧼 Grouping ingress entries by namespace..."
GROUPED=$(mktemp)
yq eval 'del(.cloudflare.ingress)' "$TEMP_FILE" > "$GROUPED"
echo " ingress:" >> "$GROUPED"
# Extract ingress entries with namespace
yq eval '.cloudflare.ingress' "$TEMP_FILE" | yq -o=json | jq -s 'group_by(.namespace)[]' | while read -r group; do
namespace=$(echo "$group" | jq -r '.[0].namespace')
echo " # ############ $namespace ############" >> "$GROUPED"
@ -85,15 +82,15 @@ yq eval '.cloudflare.ingress' "$TEMP_FILE" | yq -o=json | jq -s 'group_by(.names
echo " - hostname: $hostname" >> "$GROUPED"
echo " service: $service" >> "$GROUPED"
done
done
done >> "$GROUPED"
sed -i '/^cloudflare:/r /dev/stdin' "$GROUPED" <<< "$(tail -n +2 "$GROUPED")"
# Copy to merged location
cp "$GROUPED" "$MERGED_FILE"
echo "✅ Final merged values.yaml:"
cat "$MERGED_FILE"
# === Commit if changed ===
cd "$INFRA_CLONE"
git config user.name "woodpecker-bot"
git config user.email "ci@dvirlabs.com"
@ -108,7 +105,6 @@ else
echo " No changes to commit."
fi
# === Create Cloudflare CNAMEs ===
echo "🌐 Creating CNAME records in Cloudflare..."
CLOUDFLARE_API="https://api.cloudflare.com/client/v4"
TARGET="b50bbf48-0a2f-47ce-b73e-336b6718318b.cfargotunnel.com"
@ -116,7 +112,7 @@ TARGET="b50bbf48-0a2f-47ce-b73e-336b6718318b.cfargotunnel.com"
: "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN not set}"
: "${CLOUDFLARE_ZONE_ID:?CLOUDFLARE_ZONE_ID not set}"
yq eval '.ingress' "$GENERATED_FILE" | yq eval -o=json '.' | jq -c '.[]' | while read -r record; do
yq eval '.ingress' "$GENERATED_FILE" | yq -o=json | jq -c '.[]' | while read -r record; do
name=$(echo "$record" | jq -r '.hostname' | sed 's/\.dvirlabs\.com//')
exists=$(curl -s -X GET "$CLOUDFLARE_API/zones/$CLOUDFLARE_ZONE_ID/dns_records?type=CNAME&name=$name.dvirlabs.com" \