Created
June 26, 2023 15:53
-
-
Save dex4er/f4d59c477c86d7c4085eca7c581584c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
FILE="$1" | |
if [[ -z $FILE ]]; then | |
echo "$0 run-XXX.mocks.tar.gz" | |
exit 1 | |
fi | |
if command -v colordiff >/dev/null; then | |
diff=colordiff | |
elif diff --version | grep -qs GNU; then | |
diff="diff --color=always" | |
else | |
diff="diff" | |
fi | |
dir=mocks.$$ | |
mkdir -p $dir | |
trap "rm -rf $dir" EXIT | |
tar zxf "$FILE" -C $dir | |
sentinel2json () { | |
sed '1,2d; /module = func(path)/,$d' $dir/mock-tfplan.sentinel | hcl2json | |
} | |
for key in $(sentinel2json | jq '.. | select(.debug? != null) | .debug["0"].diff | to_entries[] | .key' -r | grep '^triggers\.' | sort -u); do | |
output=$($diff -u \ | |
<(sentinel2json | jq '.. | select(.["'"$key"'"]? != null) | .["'"$key"'"].old' -r) \ | |
<(sentinel2json | jq '.. | select(.["'"$key"'"]? != null) | .["'"$key"'"].new' -r) | |
) | |
if [[ -n $output ]]; then | |
echo "diff a/$key b/$key" | |
echo "$output" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment