Add yq key checking for abra.yml
This commit is contained in:
parent
6fdb0d64af
commit
f0a17bfd87
27
abra
27
abra
@ -1,11 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PROGRAM_NAME=$(basename "$0")
|
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
|
if [ "$1" == "-a" ]; then
|
||||||
STACK_NAME=$2
|
STACK_NAME=$2
|
||||||
shift 2
|
shift 2
|
||||||
fi
|
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
|
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 )"
|
echo "$(tput setaf 1)ERROR: \$STACK_NAME must be set (e.g. export STACK_NAME=my_cool_app)$(tput sgr0 )"
|
||||||
exit
|
exit
|
||||||
|
Loading…
Reference in New Issue
Block a user