Add yq key checking for abra.yml

This commit is contained in:
Luke Murphy 2020-09-14 00:16:46 +02:00
parent 6fdb0d64af
commit f0a17bfd87
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

27
abra
View File

@ -1,11 +1,38 @@
#!/bin/bash
PROGRAM_NAME=$(basename "$0")
ABRA_CONFIG=abra.yml
yml_pattern_exists() {
PATTERN=$1
if ! type yq > /dev/null 2>&1; then
echo "$(tput setaf 1)ERROR: yq program is not installed$(tput sgr0)"
exit
fi
if [ -f $ABRA_CONFIG ]; then
RESULT=$(yq read $ABRA_CONFIG "$PATTERN")
if [ "$RESULT" != 0 ]; then
return 0
fi
fi
return 1
}
if [ "$1" == "-a" ]; then
STACK_NAME=$2
shift 2
fi
if [ -f abra.yml ]; then
if yml_pattern_exists stack_name; then
STACK_NAME=$(yq read abra.yml stack_name)
fi
fi
if [ -z "$STACK_NAME" ]; then
echo "$(tput setaf 1)ERROR: \$STACK_NAME must be set (e.g. export STACK_NAME=my_cool_app)$(tput sgr0 )"
exit