Simplify env var checking in config plugin

All checks are now done within the commands, and we only need to ensure the config file exists.
This commit is contained in:
Jose Diaz-Gonzalez committed 2014-11-23 23:32:42 -05:00
1 parent 12194e2cc8
commit c6e39c08f0
1 file changed
+8 -18
+8 -18
View File
@@ -1,28 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# Check if name is specified ENV_FILE="$DOKKU_ROOT/$2/ENV"
if [[ $1 == config ]] || [[ $1 == config:* ]]; then ENV_FILE_TEMP="$DOKKU_ROOT/$2/ENV.tmp"
if [[ -z $2 ]]; then config_create () {
echo "Please specify an app to run the command on"
exit 1
else
APP="$2"
ENV_FILE="$DOKKU_ROOT/$APP/ENV"
ENV_FILE_TEMP="$DOKKU_ROOT/$APP/ENV.tmp"
# Check if app exists with the same name
if [ ! -d "$DOKKU_ROOT/$APP" ]; then
echo "App $APP does not exist"
exit 1
fi
[ -f $ENV_FILE ] || { [ -f $ENV_FILE ] || {
echo "-----> Creating $ENV_FILE" echo "-----> Creating $ENV_FILE"
touch $ENV_FILE touch $ENV_FILE
} }
fi }
fi
config_styled_hash () { config_styled_hash () {
vars="$1" vars="$1"
@@ -86,6 +72,7 @@ case "$1" in
exit 1 exit 1
fi fi
config_create
if [ ! -f $ENV_FILE ] || [ ! -s $ENV_FILE ] ; then if [ ! -f $ENV_FILE ] || [ ! -s $ENV_FILE ] ; then
echo "$APP has no config vars" echo "$APP has no config vars"
exit 1 exit 1
@@ -120,6 +107,7 @@ case "$1" in
exit 1 exit 1
fi fi
config_create
if [ ! -f $ENV_FILE ] || [ ! -s $ENV_FILE ] ; then if [ ! -f $ENV_FILE ] || [ ! -s $ENV_FILE ] ; then
exit 1 exit 1
fi fi
@@ -145,6 +133,7 @@ case "$1" in
exit 1 exit 1
fi fi
config_create
ENV_ADD="" ENV_ADD=""
ENV_TEMP=`cat "${ENV_FILE}"` ENV_TEMP=`cat "${ENV_FILE}"`
RESTART_APP=false RESTART_APP=false
@@ -197,6 +186,7 @@ ${var}"
exit 1 exit 1
fi fi
config_create
ENV_TEMP=`cat "${ENV_FILE}"` ENV_TEMP=`cat "${ENV_FILE}"`
VARS="${*:3}" VARS="${*:3}"