Created
April 4, 2019 08:24
-
-
Save necrophonic/860a0870520a586fed1fc5376a0ed455 to your computer and use it in GitHub Desktop.
Script to create a yaml file from a set of environment vars
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
#!/bin/bash | |
set -e | |
usage() { | |
echo "" | |
echo "Usage: env2yml <source.env> <template.yml>" | |
echo "" | |
echo "Required:" | |
echo " - source.env .... file containing env vars to source" | |
echo " - template.yml .. yaml template file to interpolate into" | |
echo "" | |
exit 1 | |
} | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
usage | |
fi | |
envs=$1 | |
template=$2 | |
source "$envs" | |
( echo "cat > final.yml <<EOF"; | |
cat "${template}"; | |
echo "EOF"; | |
) >temp.yml | |
. temp.yml | |
cat final.yml | |
rm final.yml | |
rm temp.yml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment