don't run dokku again on --* args in config plugin
This commit is contained in:
@@ -2,8 +2,6 @@
|
|||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$(dirname $0)/../common/functions"
|
source "$(dirname $0)/../common/functions"
|
||||||
|
|
||||||
DOKKU_CONFIG_RESTART=${DOKKU_CONFIG_RESTART:=true}
|
|
||||||
|
|
||||||
config_create () {
|
config_create () {
|
||||||
[ -f $ENV_FILE ] || {
|
[ -f $ENV_FILE ] || {
|
||||||
touch $ENV_FILE
|
touch $ENV_FILE
|
||||||
@@ -24,7 +22,7 @@ config_styled_hash () {
|
|||||||
|
|
||||||
while read -r word; do
|
while read -r word; do
|
||||||
KEY=$(echo $word | cut -d"=" -f1)
|
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}))
|
num_zeros=$((${#longest} - ${#KEY}))
|
||||||
zeros=" "
|
zeros=" "
|
||||||
@@ -56,19 +54,26 @@ parse_config_args() {
|
|||||||
DOKKU_CONFIG_RESTART=false
|
DOKKU_CONFIG_RESTART=false
|
||||||
;;
|
;;
|
||||||
--no-restart)
|
--no-restart)
|
||||||
ARGS=("$@") && shift 2
|
APP="$3"
|
||||||
DOKKU_CONFIG_RESTART=false dokku ${ARGS[0]} "$@"
|
ENV_FILE="$DOKKU_ROOT/$APP/ENV"
|
||||||
exit 0
|
DOKKU_CONFIG_RESTART=false
|
||||||
;;
|
|
||||||
*)
|
|
||||||
ENV_FILE="$DOKKU_ROOT/$2/ENV"
|
|
||||||
DOKKU_CONFIG_TYPE="app"
|
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"
|
verify_app_name "$2"
|
||||||
APP="$2"
|
fi
|
||||||
;;
|
fi
|
||||||
esac
|
export APP ENV_FILE DOKKU_CONFIG_TYPE DOKKU_CONFIG_RESTART
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -114,6 +119,7 @@ case "$1" in
|
|||||||
|
|
||||||
config:set)
|
config:set)
|
||||||
parse_config_args "$@"
|
parse_config_args "$@"
|
||||||
|
[[ "$2" = "--no-restart" ]] && set -- "${@:1:1}" "${@:3}"
|
||||||
|
|
||||||
if [[ -z "${*:3}" ]]; then
|
if [[ -z "${*:3}" ]]; then
|
||||||
echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]"
|
echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]"
|
||||||
@@ -166,6 +172,7 @@ ${var}"
|
|||||||
|
|
||||||
config:unset)
|
config:unset)
|
||||||
parse_config_args "$@"
|
parse_config_args "$@"
|
||||||
|
[[ "$2" = "--no-restart" ]] && set -- "${@:1:1}" "${@:3}"
|
||||||
|
|
||||||
if [[ -z $3 ]]; then
|
if [[ -z $3 ]]; then
|
||||||
echo "Usage: dokku config:unset APP KEY1 [KEY2 ...]"
|
echo "Usage: dokku config:unset APP KEY1 [KEY2 ...]"
|
||||||
|
|||||||
Reference in New Issue
Block a user