Created
May 30, 2019 07:40
-
-
Save icyflame/5efb8ca79cc339a7977b15f9d39a1ddd to your computer and use it in GitHub Desktop.
A bash script to generate a .dot file with the pre-requisite dependency graph of your LaunchDarkly setup
This file contains 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 | |
rm -f flags-output | |
rm -f dependencies | |
rm -f flat_json | |
rm -f output.dot | |
rm -f tmp | |
curl -H"Authorization: $LD_API_KEY" https://app.launchdarkly.com/api/v2/flags/default > flags-output | |
jq "[.items[] | {key, depends_on:.environments.production.prerequisites[] | {key,variation}} ]" flags-output > dependencies | |
jq '.[] | {key,on:.depends_on.key,variation:.depends_on.variation}' -c dependencies > flat_json | |
echo "digraph prequisites {" > output.dot | |
cat flat_json | awk -F'"' '{ print $4,"1arrow9",$8,"[label=\"variation",substr($11,2,1) "\"]" }' > tmp | |
cat tmp | sed "s/-/_/g" | sed "s/1arrow9/->/g" | sed "s/$/;/g" >> output.dot | |
echo "}" >> output.dot | |
echo "Ouput has been written to output.dot" >&2 | |
rm -f flags-output | |
rm -f dependencies | |
rm -f flat_json | |
rm -f tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment