apps-gitops/automation/merge_values.sh
2025-06-23 00:16:36 +03:00

20 lines
695 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "🔁 Merging new entries into: $ORIGINAL_FILE"
TEMP_FILE=$(mktemp)
cp "$ORIGINAL_FILE" "$TEMP_FILE"
yq eval '.ingress' "$GENERATED_FILE" | yq -o=json | jq -c '.[]' | while read -r new_entry; do
hostname=$(echo "$new_entry" | jq -r '.hostname')
service=$(echo "$new_entry" | jq -r '.service')
exists=$(yq e ".cloudflare.ingress[] | select(.hostname == \"$hostname\")" "$TEMP_FILE")
if [ -z "$exists" ]; then
echo " Adding $hostname$service"
yq eval ".cloudflare.ingress += [{\"hostname\": \"$hostname\", \"service\": \"$service\"}]" -i "$TEMP_FILE"
else
echo "⚠️ $hostname already exists, skipping"
fi
done
cp "$TEMP_FILE" "$MERGED_FILE"