Skip to content

Instantly share code, notes, and snippets.

@necrophonic
Created April 4, 2019 08:24
Show Gist options
  • Save necrophonic/860a0870520a586fed1fc5376a0ed455 to your computer and use it in GitHub Desktop.
Save necrophonic/860a0870520a586fed1fc5376a0ed455 to your computer and use it in GitHub Desktop.
Script to create a yaml file from a set of environment vars
#!/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