From 710c6f4e8839f3f499df85a19d41fd40be98bcfc Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Tue, 7 Jul 2015 12:31:57 -0700 Subject: [PATCH] don't run dokku again on --* args in config plugin --- plugins/config/commands | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/plugins/config/commands b/plugins/config/commands index 8d0d60f34..fd672833e 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -2,8 +2,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$(dirname $0)/../common/functions" -DOKKU_CONFIG_RESTART=${DOKKU_CONFIG_RESTART:=true} - config_create () { [ -f $ENV_FILE ] || { touch $ENV_FILE @@ -24,7 +22,7 @@ config_styled_hash () { while read -r word; do KEY=$(echo $word | cut -d"=" -f1) - VALUE=$(echo $word | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//") + VALUE=$(echo $word | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//" -e "s/\$$//g") num_zeros=$((${#longest} - ${#KEY})) zeros=" " @@ -56,19 +54,26 @@ parse_config_args() { DOKKU_CONFIG_RESTART=false ;; --no-restart) - ARGS=("$@") && shift 2 - DOKKU_CONFIG_RESTART=false dokku ${ARGS[0]} "$@" - exit 0 - ;; - *) - ENV_FILE="$DOKKU_ROOT/$2/ENV" + APP="$3" + ENV_FILE="$DOKKU_ROOT/$APP/ENV" + DOKKU_CONFIG_RESTART=false DOKKU_CONFIG_TYPE="app" + set -- "${@:1:1}" "${@:3}" + esac - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + APP=${APP:="$2"} + ENV_FILE=${ENV_FILE:="$DOKKU_ROOT/$APP/ENV"} + DOKKU_CONFIG_TYPE=${DOKKU_CONFIG_TYPE:="app"} + DOKKU_CONFIG_RESTART=${DOKKU_CONFIG_RESTART:=true} + + if [[ "$DOKKU_CONFIG_TYPE" = "app" ]]; then + if [[ -z $APP ]]; then + echo "Please specify an app to run the command on" >&2 && exit 1 + else verify_app_name "$2" - APP="$2" - ;; - esac + fi + fi + export APP ENV_FILE DOKKU_CONFIG_TYPE DOKKU_CONFIG_RESTART } case "$1" in @@ -114,6 +119,7 @@ case "$1" in config:set) parse_config_args "$@" + [[ "$2" = "--no-restart" ]] && set -- "${@:1:1}" "${@:3}" if [[ -z "${*:3}" ]]; then echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]" @@ -166,6 +172,7 @@ ${var}" config:unset) parse_config_args "$@" + [[ "$2" = "--no-restart" ]] && set -- "${@:1:1}" "${@:3}" if [[ -z $3 ]]; then echo "Usage: dokku config:unset APP KEY1 [KEY2 ...]"