diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 77c240dcf..2fbf7b77b 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -235,8 +235,8 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-hello-default() { declare desc="prints Hello \$APP" - declare cmd="hello" argv=("$@") - [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare cmd="hello" + [[ "$1" == "$cmd" ]] && shift 1 # Support --app/$DOKKU_APP_NAME flag # Use the following lines to reorder args into "$cmd $DOKKU_APP_NAME $@"" [[ -n $DOKKU_APP_NAME ]] && set -- $DOKKU_APP_NAME $@ @@ -263,8 +263,8 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-hello-world() { declare desc="prints Hello world" - declare cmd="hello:world" argv=("$@") - [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare cmd="hello:world" + [[ "$1" == "$cmd" ]] && shift 1 echo "Hello world" } diff --git a/plugins/00_dokku-standard/subcommands/report b/plugins/00_dokku-standard/subcommands/report index 67a29e175..64ceccc8d 100755 --- a/plugins/00_dokku-standard/subcommands/report +++ b/plugins/00_dokku-standard/subcommands/report @@ -5,8 +5,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-report() { declare desc="reports dokku vitals for troubleshooting" - local cmd="report" - declare APP="$2" + declare cmd="report" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" dokku_log_info1 "uname: $(uname -a)" dokku_log_info1 "memory: " diff --git a/plugins/00_dokku-standard/subcommands/run b/plugins/00_dokku-standard/subcommands/run index e7a82c1df..aee53826a 100755 --- a/plugins/00_dokku-standard/subcommands/run +++ b/plugins/00_dokku-standard/subcommands/run @@ -2,12 +2,12 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/config/functions" cmd-run() { declare desc="runs command in container based on app image" - declare cmd="run" APP="" - shift + declare cmd="run" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="" declare -a RUN_ENV RUN_ENV=() diff --git a/plugins/00_dokku-standard/subcommands/urls b/plugins/00_dokku-standard/subcommands/urls index 8a2be2cbe..8c37b1e53 100755 --- a/plugins/00_dokku-standard/subcommands/urls +++ b/plugins/00_dokku-standard/subcommands/urls @@ -4,8 +4,11 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-urls() { + declare desc="reports dokku vitals for troubleshooting" + declare cmd="url" + declare APP="$2" + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - local APP="$2" get_app_urls "$@" } diff --git a/plugins/20_events/subcommands/default b/plugins/20_events/subcommands/default index 93f7e646f..fdbbbf36b 100755 --- a/plugins/20_events/subcommands/default +++ b/plugins/20_events/subcommands/default @@ -5,9 +5,12 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-events-default() { declare desc="shows contents of dokku events log" - local cmd="events" + declare cmd="events" + [[ "$1" == "$cmd" ]] && shift 1 + declare TAIL="$1" + if [[ -f $DOKKU_EVENTS_LOGFILE ]]; then - if [[ $2 == "-t" ]]; then + if [[ "$TAIL" == "-t" ]]; then tail -F "$DOKKU_EVENTS_LOGFILE" else tail -n 100 "$DOKKU_EVENTS_LOGFILE" diff --git a/plugins/20_events/subcommands/list b/plugins/20_events/subcommands/list index c8e22dc65..b71e2ad3e 100755 --- a/plugins/20_events/subcommands/list +++ b/plugins/20_events/subcommands/list @@ -5,7 +5,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-events-list() { declare desc="lists enabled events" - local cmd="events:list" + declare cmd="events:list" + [[ "$1" == "$cmd" ]] && shift 1 + local PLUGIN_DIR="$(dirname "$0")/.." local logged hook diff --git a/plugins/20_events/subcommands/off b/plugins/20_events/subcommands/off index 6adf893d0..f19559dbc 100755 --- a/plugins/20_events/subcommands/off +++ b/plugins/20_events/subcommands/off @@ -5,7 +5,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-events-off() { declare desc="disables dokku events logger" - local cmd="events:off" + declare cmd="events:off" + [[ "$1" == "$cmd" ]] && shift 1 + echo "Disabling dokku events logger" rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS" } diff --git a/plugins/20_events/subcommands/on b/plugins/20_events/subcommands/on index 15738c528..4d7af3ecc 100755 --- a/plugins/20_events/subcommands/on +++ b/plugins/20_events/subcommands/on @@ -5,7 +5,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-events-on() { declare desc="enables dokku events logger" - local cmd="events:on" + declare cmd="events:on" + [[ "$1" == "$cmd" ]] && shift 1 + echo "Enabling dokku events logger" [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc" echo "export DOKKU_EVENTS=1" >"$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS" diff --git a/plugins/apps/internal-functions b/plugins/apps/internal-functions index 7ed59bcf6..87f5546aa 100755 --- a/plugins/apps/internal-functions +++ b/plugins/apps/internal-functions @@ -6,9 +6,10 @@ set -eo pipefail cmd-apps-report() { declare desc="displays the app report for one or more apps" - local cmd="apps:report" + declare cmd="apps:report" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" INFO_FLAG="$2" local INSTALLED_APPS=$(dokku_apps) - local APP="$2" INFO_FLAG="$3" if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -80,7 +81,8 @@ cmd-apps-report-single() { cmd-apps-list() { declare desc="lists all apps" - local cmd="apps" + declare cmd="apps" + [[ "$1" == "$cmd" ]] && shift 1 local app dokku_log_info2_quiet "My Apps" diff --git a/plugins/apps/subcommands/clone b/plugins/apps/subcommands/clone index 21b405d11..7ba17a6a9 100755 --- a/plugins/apps/subcommands/clone +++ b/plugins/apps/subcommands/clone @@ -7,11 +7,10 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions" cmd-apps-clone() { declare desc="clones an app" - declare cmd="apps:clone" argv=("$@") - [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare cmd="apps:clone" + [[ "$1" == "$cmd" ]] && shift 1 declare OLD_APP="$1" NEW_APP="$2" - local IGNORE_EXISTING=false - local SKIP_REBUILD=false + local IGNORE_EXISTING=false SKIP_REBUILD=false for arg in "$@"; do [[ "$arg" == "--skip-deploy" ]] && shift 1 && SKIP_REBUILD=true diff --git a/plugins/apps/subcommands/create b/plugins/apps/subcommands/create index ca0b1783d..0a538f940 100755 --- a/plugins/apps/subcommands/create +++ b/plugins/apps/subcommands/create @@ -5,8 +5,11 @@ source "$PLUGIN_AVAILABLE_PATH/apps/functions" cmd-apps-create() { declare desc="creates app via command line" - local cmd="apps:create" - apps_create "$2" + declare cmd="apps:create" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + apps_create "$APP" } cmd-apps-create "$@" diff --git a/plugins/apps/subcommands/destroy b/plugins/apps/subcommands/destroy index 1cdd0c97c..6accc0a29 100755 --- a/plugins/apps/subcommands/destroy +++ b/plugins/apps/subcommands/destroy @@ -6,11 +6,14 @@ source "$PLUGIN_AVAILABLE_PATH/apps/functions" cmd-apps-destroy() { declare desc="destroys an app" - local cmd="apps:destroy" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - [[ "$2" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory" - [[ "$3" == "force" ]] && export DOKKU_APPS_FORCE_DELETE=1 - local APP="$2" + declare cmd="apps:destroy" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" FORCE="$2" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ "$APP" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory" + [[ "$FORCE" == "force" ]] && export DOKKU_APPS_FORCE_DELETE=1 + apps_destroy "$APP" } diff --git a/plugins/apps/subcommands/exists b/plugins/apps/subcommands/exists index bb3c6b9fc..1bbc9113e 100755 --- a/plugins/apps/subcommands/exists +++ b/plugins/apps/subcommands/exists @@ -5,7 +5,7 @@ source "$PLUGIN_AVAILABLE_PATH/apps/functions" cmd-apps-exist() { declare desc="checks if an app exists" - local cmd="apps:exists" + declare cmd="apps:exists" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" diff --git a/plugins/apps/subcommands/lock b/plugins/apps/subcommands/lock index 0905c8952..4659902c4 100755 --- a/plugins/apps/subcommands/lock +++ b/plugins/apps/subcommands/lock @@ -9,10 +9,9 @@ cmd-apps-lock() { declare cmd="apps:lock" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" + verify_app_name "$APP" - touch "$DOKKU_ROOT/$APP/.deploy.lock" || dokku_log_fail "Unable to create deploy lock" - dokku_log_info1 "Deploy lock created" } diff --git a/plugins/apps/subcommands/locked b/plugins/apps/subcommands/locked index 5d1391e13..6dc51b779 100755 --- a/plugins/apps/subcommands/locked +++ b/plugins/apps/subcommands/locked @@ -9,6 +9,7 @@ cmd-apps-locked() { declare cmd="apps:locked" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" + verify_app_name "$APP" local LOCKED="$(apps_is_locked "$APP")" diff --git a/plugins/apps/subcommands/rename b/plugins/apps/subcommands/rename index 1cd5a2f28..0ce98e154 100755 --- a/plugins/apps/subcommands/rename +++ b/plugins/apps/subcommands/rename @@ -7,11 +7,12 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions" cmd-apps-rename() { declare desc="renames an app" - local cmd="apps:rename" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - [[ -d "$DOKKU_ROOT/$3" ]] && dokku_log_fail "Name is already taken" - local OLD_APP="$2" - local NEW_APP="$3" + declare cmd="apps:rename" + [[ "$1" == "$cmd" ]] && shift 1 + declare OLD_APP="$1" NEW_APP="$2" + + [[ -z "$OLD_APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -d "$DOKKU_ROOT/$NEW_APP" ]] && dokku_log_fail "Name is already taken" local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache" local OLD_CACHE_HOST_DIR="$DOKKU_HOST_ROOT/$OLD_APP/cache" diff --git a/plugins/certs/internal-functions b/plugins/certs/internal-functions index 76cdeaa92..231a6ed70 100755 --- a/plugins/certs/internal-functions +++ b/plugins/certs/internal-functions @@ -6,9 +6,10 @@ set -eo pipefail cmd-certs-report() { declare desc="displays an ssl report for one or more apps" - local cmd="certs:report" + declare cmd="certs:report" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" INFO_FLAG="$2" local INSTALLED_APPS=$(dokku_apps) - local APP="$2" INFO_FLAG="$3" if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -74,10 +75,12 @@ cmd-certs-report-single() { cmd-certs-info() { # This is here because it's used in both the info and the default declare desc="prints SSL certificate info for app" - local cmd="certs:info" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - verify_app_name "$2" - local APP="$2" + declare cmd="certs:info" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$APP" local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" if is_ssl_enabled "$APP"; then diff --git a/plugins/certs/subcommands/add b/plugins/certs/subcommands/add index 5d0a084e4..b86ba2f10 100755 --- a/plugins/certs/subcommands/add +++ b/plugins/certs/subcommands/add @@ -30,12 +30,12 @@ is_file_import() { cmd-certs-set() { declare desc="imports an SSL cert/key combo either on STDIN via a tarball or from specified cert/key filenames" - local cmd="$1" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - verify_app_name "$2" - local APP="$2" - local CRT_FILE="$3" - local KEY_FILE="$4" + declare cmd="$1" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" CRT_FILE="$2" KEY_FILE="$3" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$APP" local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" if is_file_import "$CRT_FILE" "$KEY_FILE"; then diff --git a/plugins/certs/subcommands/generate b/plugins/certs/subcommands/generate index bb6ee7099..8f82e8a32 100755 --- a/plugins/certs/subcommands/generate +++ b/plugins/certs/subcommands/generate @@ -6,8 +6,10 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-certs-generate() { declare desc="generates a self-signed SSL certificate/key combo" - declare APP="$2" DOMAIN="$3" - local cmd="certs:generate" + declare cmd="certs:generate" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" DOMAIN="$2" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$APP" local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" diff --git a/plugins/certs/subcommands/remove b/plugins/certs/subcommands/remove index ac6b02bf2..717dc7e57 100755 --- a/plugins/certs/subcommands/remove +++ b/plugins/certs/subcommands/remove @@ -5,10 +5,12 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-certs-remove() { declare desc="removes SSL cert/key from specified app" - local cmd="certs:remove" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - verify_app_name "$2" - local APP="$2" + declare cmd="certs:remove" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$APP" local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" if [[ -d "$APP_SSL_PATH" ]]; then diff --git a/plugins/checks/internal-functions b/plugins/checks/internal-functions index 75dc5d3bf..bf78f4c96 100755 --- a/plugins/checks/internal-functions +++ b/plugins/checks/internal-functions @@ -6,9 +6,10 @@ set -eo pipefail cmd-checks-report() { declare desc="shows reports for an app" - local cmd="checks:report" + declare cmd="checks:report" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" INFO_FLAG="$2" local INSTALLED_APPS=$(dokku_apps) - local APP="$2" INFO_FLAG="$3" if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" diff --git a/plugins/checks/subcommands/default b/plugins/checks/subcommands/default index 8c4b0f876..ffe4a5fdb 100755 --- a/plugins/checks/subcommands/default +++ b/plugins/checks/subcommands/default @@ -6,11 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/checks/functions" cmd-checks-default() { declare desc="displays app zero-downtime checks status" - local cmd="checks" + declare cmd="checks" [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + local APPS=$(dokku_apps) - if [[ -n "$1" ]]; then - local APPS="$1" + if [[ -n "$APP" ]]; then + local APPS="$APP" fi dokku_log_warn "Deprecated: Please use checks:report" diff --git a/plugins/checks/subcommands/disable b/plugins/checks/subcommands/disable index 85b7aae58..8f6058cc2 100755 --- a/plugins/checks/subcommands/disable +++ b/plugins/checks/subcommands/disable @@ -6,9 +6,10 @@ source "$PLUGIN_AVAILABLE_PATH/checks/functions" cmd-checks-disable() { declare desc="disable zero-downtime checks for app/proctypes" - local cmd="checks:disable" + declare cmd="checks:disable" [[ "$1" == "$cmd" ]] && shift 1 - local APP="$1" + declare APP="$1" + verify_app_name "$APP" local PROCTYPES="${2:-_all_}" local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED || true) diff --git a/plugins/checks/subcommands/enable b/plugins/checks/subcommands/enable index 3db35d07e..9431aca0b 100755 --- a/plugins/checks/subcommands/enable +++ b/plugins/checks/subcommands/enable @@ -6,9 +6,10 @@ source "$PLUGIN_AVAILABLE_PATH/checks/functions" cmd-checks-enable() { declare desc="enable zero-downtime checks for app/proctypes" - local cmd="checks:enable" + declare cmd="checks:enable" [[ "$1" == "$cmd" ]] && shift 1 - local APP="$1" + declare APP="$1" + verify_app_name "$APP" local PROCTYPES="${2:-_all_}" diff --git a/plugins/checks/subcommands/run b/plugins/checks/subcommands/run index fb50a8d34..3a5e97816 100755 --- a/plugins/checks/subcommands/run +++ b/plugins/checks/subcommands/run @@ -69,9 +69,10 @@ check_process() { cmd-checks-run() { declare desc="run zero-downtime checks for app/proctypes" - local cmd="checks:run" + declare cmd="checks:run" [[ "$1" == "$cmd" ]] && shift 1 - local APP="$1" + declare APP="$1" + verify_app_name "$APP" local PROCTYPES="${2:-_all_}" diff --git a/plugins/checks/subcommands/skip b/plugins/checks/subcommands/skip index 8c3e57137..ff8719a1f 100755 --- a/plugins/checks/subcommands/skip +++ b/plugins/checks/subcommands/skip @@ -6,9 +6,10 @@ source "$PLUGIN_AVAILABLE_PATH/checks/functions" cmd-checks-skip() { declare desc="skip zero-downtime checks for app/proctypes" - local cmd="checks:skip" + declare cmd="checks:skip" [[ "$1" == "$cmd" ]] && shift 1 - local APP="$1" + declare APP="$1" + verify_app_name "$APP" local PROCTYPES="${2:-_all_}" local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED || true) diff --git a/plugins/common/functions b/plugins/common/functions index ddb074bde..294472f3c 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -295,8 +295,7 @@ get_running_image_tag() { is_image_herokuish_based() { declare desc="returns true if app image is based on herokuish" - declare IMAGE="$1" - declare APP="$2" + declare IMAGE="$1" APP="$2" local DOKKU_APP_USER if [[ -n "$APP" ]]; then DOKKU_APP_USER=$(config_get "$APP" DOKKU_APP_USER || true) diff --git a/plugins/docker-options/internal-functions b/plugins/docker-options/internal-functions index 5d3f4494f..870c9ebf6 100755 --- a/plugins/docker-options/internal-functions +++ b/plugins/docker-options/internal-functions @@ -6,9 +6,10 @@ set -eo pipefail cmd-docker-options-report() { declare desc="displays a docker options report for one or more apps" - local cmd="docker-options:report" + declare cmd="docker-options:report" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" INFO_FLAG="$2" local INSTALLED_APPS=$(dokku_apps) - local APP="$2" INFO_FLAG="$3" if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" diff --git a/plugins/docker-options/subcommands/add b/plugins/docker-options/subcommands/add index 799c9831e..5d1a692a8 100755 --- a/plugins/docker-options/subcommands/add +++ b/plugins/docker-options/subcommands/add @@ -6,11 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" cmd-docker-options-add() { declare desc="Add a docker option to application" - local cmd="docker-options:add" + declare cmd="docker-options:add" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" - verify_app_name "$2" && local APP="$2" - read -ra passed_phases <<<"$(get_phases "$3")" - shift 3 # everything else passed is the docker option + verify_app_name "$2" + read -ra passed_phases <<<"$(get_phases "$2")" + shift 2 # everything else passed is the docker option local passed_docker_option="$*" [[ -z "$passed_docker_option" ]] && dokku_log_fail "Please specify docker options to add to the phase" add_passed_docker_option passed_phases[@] "${passed_docker_option[@]}" diff --git a/plugins/docker-options/subcommands/clear b/plugins/docker-options/subcommands/clear index 6a6c6ae9f..66b331ac0 100755 --- a/plugins/docker-options/subcommands/clear +++ b/plugins/docker-options/subcommands/clear @@ -6,8 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" cmd-docker-options-clear() { declare desc="clear a docker options from application" - declare cmd="docker-options:clear" argv=("$@") - [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare cmd="docker-options:clear" + [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" PHASES="$2" [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" diff --git a/plugins/docker-options/subcommands/default b/plugins/docker-options/subcommands/default index 9ffe4fe01..ba6e59a96 100755 --- a/plugins/docker-options/subcommands/default +++ b/plugins/docker-options/subcommands/default @@ -6,11 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" cmd-docker-options-default() { declare desc="Display applications docker options" - local cmd="docker-options" - dokku_log_warn "Deprecated: Please use docker-options:report" + declare cmd="docker-options" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" - verify_app_name "$2" && local APP="$2" - read -ra passed_phases <<<"$(get_phases "$3")" + dokku_log_warn "Deprecated: Please use docker-options:report" + verify_app_name "$APP" + read -ra passed_phases <<<"$(get_phases "$2")" if [[ ! "${passed_phases[@]}" ]]; then display_all_phases_options else diff --git a/plugins/docker-options/subcommands/remove b/plugins/docker-options/subcommands/remove index a57a8080d..f258a0b34 100755 --- a/plugins/docker-options/subcommands/remove +++ b/plugins/docker-options/subcommands/remove @@ -6,11 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" cmd-docker-options-remove() { declare desc="Remove a docker option from application" - local cmd="docker-options:remove" + declare cmd="docker-options:remove" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" - verify_app_name "$2" && local APP="$2" - read -ra passed_phases <<<"$(get_phases "$3")" - shift 3 # everything else passed is the docker option + verify_app_name "$APP" + read -ra passed_phases <<<"$(get_phases "$2")" + shift 2 # everything else passed is the docker option # shellcheck disable=SC2154 [[ -z ${passed_docker_option="$@"} ]] && dokku_log_fail "Please specify docker options to remove from the phase" remove_passed_docker_option passed_phases[@] "${passed_docker_option[@]}" diff --git a/plugins/domains/internal-functions b/plugins/domains/internal-functions index f1d193448..9ca372a84 100755 --- a/plugins/domains/internal-functions +++ b/plugins/domains/internal-functions @@ -6,9 +6,10 @@ set -eo pipefail cmd-domains-report() { declare desc="displays a domains report for one or more apps" - local cmd="domains:report" + declare cmd="domains:report" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" INFO_FLAG="$2" local INSTALLED_APPS=$(dokku_apps) - local APP="$2" INFO_FLAG="$3" if [[ "$APP" == "--global" ]]; then cmd-domains-report-single "$APP" "$INFO_FLAG" diff --git a/plugins/domains/subcommands/add b/plugins/domains/subcommands/add index e8e8cd5b9..2178add1c 100755 --- a/plugins/domains/subcommands/add +++ b/plugins/domains/subcommands/add @@ -6,11 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-add() { declare desc="adds domains to app via command line" - local cmd="domains:add" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - [[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 [ ...]" + declare cmd="domains:add" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" DOMAIN_NAME="$2" - shift 1 + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 [ ...]" domains_add "$@" } diff --git a/plugins/domains/subcommands/add-global b/plugins/domains/subcommands/add-global index 4ccf1b825..0a0816d32 100755 --- a/plugins/domains/subcommands/add-global +++ b/plugins/domains/subcommands/add-global @@ -6,10 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-add-global() { declare desc="add global domain names via command line" - local cmd="domains:add-global" - [[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 [ ...]" + declare cmd="domains:add-global" + [[ "$1" == "$cmd" ]] && shift 1 + declare DOMAIN_NAME="$1" - shift 1 + [[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 [ ...]" domains_add_global "$@" } diff --git a/plugins/domains/subcommands/clear b/plugins/domains/subcommands/clear index 759c132a2..965f14165 100755 --- a/plugins/domains/subcommands/clear +++ b/plugins/domains/subcommands/clear @@ -6,10 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-clear() { declare desc="clear all app domains" - local cmd="domains:clear" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - verify_app_name "$2" - local APP="$2" + declare cmd="domains:clear" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$APP" local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" rm -f "$APP_VHOST_PATH" diff --git a/plugins/domains/subcommands/clear-global b/plugins/domains/subcommands/clear-global index 9024a6430..ff7ae757b 100755 --- a/plugins/domains/subcommands/clear-global +++ b/plugins/domains/subcommands/clear-global @@ -6,8 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-clear-global() { declare desc="clear global domain names via command line" - local cmd="domains:clear-global" - shift 1 + declare cmd="domains:clear-global" + [[ "$1" == "$cmd" ]] && shift 1 dokku_log_info1_quiet "Clearing global domains" domains_clear_global "$@" diff --git a/plugins/domains/subcommands/default b/plugins/domains/subcommands/default index 6b9650fa1..49f3e9087 100755 --- a/plugins/domains/subcommands/default +++ b/plugins/domains/subcommands/default @@ -6,8 +6,9 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-default() { declare desc="print app domains" - local cmd="domains" - local APP="$2" + declare cmd="domains" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" dokku_log_warn "Deprecated: Please use domains:report" if [[ "$(is_global_vhost_enabled)" == "true" ]]; then diff --git a/plugins/domains/subcommands/disable b/plugins/domains/subcommands/disable index 224176e30..0757a77fe 100755 --- a/plugins/domains/subcommands/disable +++ b/plugins/domains/subcommands/disable @@ -6,9 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-disable() { declare desc="disable domains/VHOST support via command line" - local cmd="domains:disable" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - domains_disable "$2" + declare cmd="domains:disable" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + domains_disable "$APP" } cmd-domains-disable "$@" diff --git a/plugins/domains/subcommands/enable b/plugins/domains/subcommands/enable index 5cb4d10da..d4f641cb5 100755 --- a/plugins/domains/subcommands/enable +++ b/plugins/domains/subcommands/enable @@ -6,9 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-enable() { declare desc="enable domains/VHOST support via command line" - local cmd="domains:enable" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - domains_enable "$2" + declare cmd="domains:enable" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + domains_enable "$APP" } cmd-domains-enable "$@" diff --git a/plugins/domains/subcommands/remove b/plugins/domains/subcommands/remove index 0eaf71cf1..e9ee9837a 100755 --- a/plugins/domains/subcommands/remove +++ b/plugins/domains/subcommands/remove @@ -6,11 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-remove() { declare desc="removes domains from app via command line" - local cmd="domains:remove" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - [[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 [ ...]" + declare cmd="domains:remove" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" DOMAIN_NAME="$2" - shift 1 + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 [ ...]" domains_remove "$@" } diff --git a/plugins/domains/subcommands/remove-global b/plugins/domains/subcommands/remove-global index 574184392..1c2e4818d 100755 --- a/plugins/domains/subcommands/remove-global +++ b/plugins/domains/subcommands/remove-global @@ -6,10 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-remove-global() { declare desc="remove global domain names via command line" - local cmd="domains:remove-global" - [[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 [ ...]" + declare cmd="domains:remove-global" + [[ "$1" == "$cmd" ]] && shift 1 + declare DOMAIN_NAME="$1" - shift 1 + [[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 [ ...]" domains_remove_global "$@" } diff --git a/plugins/domains/subcommands/set b/plugins/domains/subcommands/set index 2b8ace952..fdda804fa 100755 --- a/plugins/domains/subcommands/set +++ b/plugins/domains/subcommands/set @@ -6,11 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-set() { declare desc="set domains for app via command line" - local cmd="domains:set" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - [[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 [ ...]" + declare cmd="domains:set" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" DOMAIN_NAME="$2" - shift 1 + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 [ ...]" domains_set "$@" } diff --git a/plugins/domains/subcommands/set-global b/plugins/domains/subcommands/set-global index 88f9a5c99..9e8bd03e2 100755 --- a/plugins/domains/subcommands/set-global +++ b/plugins/domains/subcommands/set-global @@ -6,10 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-set-global() { declare desc="set global domain names via command line" - local cmd="domains:set-global" - [[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 [ ...]" + declare cmd="domains:set-global" + [[ "$1" == "$cmd" ]] && shift 1 + declare DOMAIN_NAME="$1" - shift 1 + [[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 [ ...]" domains_set_global "$@" } diff --git a/plugins/domains/subcommands/setup b/plugins/domains/subcommands/setup index 57be41235..007ce1ec8 100755 --- a/plugins/domains/subcommands/setup +++ b/plugins/domains/subcommands/setup @@ -6,9 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-setup() { declare desc="setup domains to default state via command line" - local cmd="domains:setup" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - domains_setup "$2" + declare cmd="domains:setup" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + domains_setup "$APP" } cmd-domains-setup "$@" diff --git a/plugins/enter/subcommands/default b/plugins/enter/subcommands/default index 397457197..efab27c18 100755 --- a/plugins/enter/subcommands/default +++ b/plugins/enter/subcommands/default @@ -6,15 +6,16 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" cmd-enter-default() { declare desc="enters running app container of specified proc type" - local cmd="enter" - local APP="$2" - local CONTAINER_TYPE="$3" + declare cmd="enter" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" CONTAINER_TYPE="$2" CONTAINER_ID_FLAG="$3" CONTAINER_ID="$4" + local IMAGE_TAG=$(get_running_image_tag "$APP") local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG") verify_app_name "$APP" local AVAILABLE_CONTAINER_TYPES=($(get_app_running_container_types "$APP")) - if [[ -z "$3" ]]; then + if [[ -z "$CONTAINER_TYPE" ]]; then if [[ ${#AVAILABLE_CONTAINER_TYPES[@]} -gt 1 ]]; then dokku_log_warn "No container type specified." dokku_log_fail "Available types for app ($APP): ${AVAILABLE_CONTAINER_TYPES[*]}" @@ -23,9 +24,9 @@ cmd-enter-default() { fi fi - if [[ "$3" == "--container-id" ]]; then + if [[ "$CONTAINER_ID_FLAG" == "--container-id" ]]; then local DOKKU_APP_CIDS=($(get_app_container_ids "$APP")) - if [[ -z "$4" ]]; then + if [[ -z "$CONTAINER_ID" ]]; then dokku_log_warn "No container id specified." dokku_log_fail "Available ids for app ($APP): ${DOKKU_APP_CIDS[*]}" fi @@ -34,7 +35,7 @@ cmd-enter-default() { dokku_log_fail "Available ids for app ($APP): ${DOKKU_APP_CIDS[*]}" fi local ID=$(printf -- '%s\n' "${DOKKU_APP_CIDS[@]}" | grep -e "^$4") - shift 4 + shift 3 else local DOKKU_APP_CIDS=($(get_app_container_ids "$APP" "$CONTAINER_TYPE")) local ID=${DOKKU_APP_CIDS[0]} @@ -42,10 +43,10 @@ cmd-enter-default() { dokku_log_warn "No containers found for type '$CONTAINER_TYPE'" dokku_log_fail "Available types for app ($APP): ${AVAILABLE_CONTAINER_TYPES[*]}" fi - if [[ $3 ]]; then - shift 3 - else + if [[ "$CONTAINER_ID_FLAG" ]]; then shift 2 + else + shift 1 fi fi diff --git a/plugins/git/functions b/plugins/git/functions index 123b0e6a9..939e5d487 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -109,7 +109,7 @@ git_trigger_build() { git_deploy_branch() { declare desc="retrieve the deploy branch for a given application" - local cmd="git-hook" + declare cmd="git-hook" local APP="$1" local DOKKU_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "$APP" "deploy-branch" "")" @@ -125,9 +125,11 @@ git_deploy_branch() { cmd-git-hook() { declare desc="kick off receive-app trigger from git prereceive hook" - local cmd="git-hook" - local APP="$2" + declare cmd="git-hook" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" local DOKKU_DEPLOY_BRANCH + is_valid_app_name "$APP" DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")" @@ -198,7 +200,9 @@ git_receive_app() { cmd-git-upload-pack() { declare desc="executes git-upload-pack" declare cmd="git-upload-pack" - declare APP="$2" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + APP="$(echo "$APP" | perl -pe 's/(?/dev/null 2>&1 && apps_maybe_create "$APP" @@ -210,7 +214,7 @@ cmd-git-upload-pack() { cmd-git-glob() { declare desc="catch-all for any other git-* commands" - local cmd="git-*" + declare cmd="git-*" local APP="$(echo "$2" | perl -pe 's/(?/dev/null" RETURN INT TERM EXIT diff --git a/plugins/ssh-keys/subcommands/remove b/plugins/ssh-keys/subcommands/remove index 4e2167eb0..b8587bf52 100755 --- a/plugins/ssh-keys/subcommands/remove +++ b/plugins/ssh-keys/subcommands/remove @@ -6,12 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" cmd-ssh-keys-remove() { declare desc="Removes key from authorized_keys" - local cmd="ssh-keys:remove" - shift - local name="$1" + declare cmd="ssh-keys:remove" + [[ "$1" == "$cmd" ]] && shift 1 + declare NAME="$1" + verify_ssh_key_file - [[ -z $1 ]] && dokku_log_fail "A name is required to remove a key, ie: dokku ssh-keys:remove " - sshcommand acl-remove dokku "$name" || dokku_log_fail "sshcommand returned an error $?" + [[ -z "$NAME" ]] && dokku_log_fail "A name is required to remove a key, ie: dokku ssh-keys:remove " + sshcommand acl-remove dokku "$NAME" || dokku_log_fail "sshcommand returned an error $?" } cmd-ssh-keys-remove "$@" diff --git a/plugins/storage/internal-functions b/plugins/storage/internal-functions index efa35d4b7..31c292790 100755 --- a/plugins/storage/internal-functions +++ b/plugins/storage/internal-functions @@ -7,9 +7,10 @@ set -eo pipefail cmd-storage-report() { declare desc="displays a storage report for one or more apps" - local cmd="storage:report" + declare cmd="storage:report" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" INFO_FLAG="$2" local INSTALLED_APPS=$(dokku_apps) - local APP="$2" INFO_FLAG="$3" if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -77,10 +78,13 @@ fn-storage-bind-mounts() { cmd-storage-list() { declare desc="List all bound mounts" - local cmd="storage:list" + declare cmd="storage:list" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + local passed_phases="deploy" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - verify_app_name "$2" && local APP="$2" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$APP" dokku_log_quiet "$APP volume bind-mounts:" get_bind_mounts "$(get_phase_file_path "$passed_phases")" } diff --git a/plugins/storage/subcommands/mount b/plugins/storage/subcommands/mount index 1887c1af6..57db21a75 100755 --- a/plugins/storage/subcommands/mount +++ b/plugins/storage/subcommands/mount @@ -7,11 +7,14 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" cmd-storage-mount() { declare desc="Add bind-mount, redeploy app if running" - local cmd="storage:mount" + declare cmd="storage:mount" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" MOUNT_PATH="$2" local passed_phases=(deploy run) - [[ -z $3 || $4 ]] && dokku_log_fail "storage:mount requires an app and a two paths divided by colon." - verify_app_name "$2" && local APP="$2" - verify_paths "$3" && local MOUNT_PATH="$3" + + [[ -z "$APP" || "$MOUNT_PATH" ]] && dokku_log_fail "storage:mount requires an app and a two paths divided by colon." + verify_app_name "$APP" + verify_paths "$MOUNT_PATH" check_if_path_exists "$MOUNT_PATH" "$(get_phase_file_path "${passed_phases[@]}")" && dokku_log_fail "Mount path already exists." add_passed_docker_option passed_phases[@] "-v $MOUNT_PATH" } diff --git a/plugins/storage/subcommands/unmount b/plugins/storage/subcommands/unmount index 9ba3a8067..f5d77c06c 100755 --- a/plugins/storage/subcommands/unmount +++ b/plugins/storage/subcommands/unmount @@ -7,11 +7,14 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" cmd-storage-unmount() { declare desc="Remove bind-mount, restart app if running" - local cmd="storage:unmount" + declare cmd="storage:unmount" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" MOUNT_PATH="$2" local passed_phases=(deploy run) - [[ -z $3 || $4 ]] && dokku_log_fail "storage:unmount requires an app and a two paths divided by colon." - verify_app_name "$2" && local APP="$2" - verify_paths "$3" && local MOUNT_PATH="$3" + + [[ -z "$APP" || "$MOUNT_PATH" ]] && dokku_log_fail "storage:unmount requires an app and a two paths divided by colon." + verify_app_name "$APP" + verify_paths "$MOUNT_PATH" check_if_path_exists "$MOUNT_PATH" "$(get_phase_file_path "${passed_phases[@]}")" || dokku_log_fail "Mount path does not exist." remove_passed_docker_option passed_phases[@] "-v $MOUNT_PATH" } diff --git a/plugins/tags/subcommands/create b/plugins/tags/subcommands/create index 02bfc3f39..ea49d1506 100755 --- a/plugins/tags/subcommands/create +++ b/plugins/tags/subcommands/create @@ -6,13 +6,14 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" cmd-tags-create() { declare desc="creates an images tag for app via command line" - local cmd="tags:create" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - local APP="$2" - local IMAGE_TAG="$3" - local IMAGE_REPO=$(get_app_image_repo "$APP") + declare cmd="tags:create" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" IMAGE_TAG="$2" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$APP" + local IMAGE_REPO=$(get_app_image_repo "$APP") local DOKKU_SCHEDULER=$(get_app_scheduler "$APP") plugn trigger scheduler-tags-create "$DOKKU_SCHEDULER" "$APP" "$IMAGE_REPO:latest" "$IMAGE_REPO:$IMAGE_TAG" diff --git a/plugins/tags/subcommands/default b/plugins/tags/subcommands/default index 4710cbf26..e740f5983 100755 --- a/plugins/tags/subcommands/default +++ b/plugins/tags/subcommands/default @@ -5,12 +5,14 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-tags-default() { declare desc="shows docker images tags for app via command line" - local cmd="tags" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - local APP="$2" - local IMAGE_REPO=$(get_app_image_repo "$APP") + declare cmd="tags" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$APP" + local IMAGE_REPO=$(get_app_image_repo "$APP") dokku_log_info2_quiet "Image tags for $IMAGE_REPO" "$DOCKER_BIN" image list "$IMAGE_REPO" } diff --git a/plugins/tags/subcommands/deploy b/plugins/tags/subcommands/deploy index 41461ce8c..227b0f30a 100755 --- a/plugins/tags/subcommands/deploy +++ b/plugins/tags/subcommands/deploy @@ -5,13 +5,14 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-tags-deploy() { declare desc="deploys an app with a given tagged image via command line" - local cmd="tags:deploy" - declare APP="$2" IMAGE_TAG="$3" - local IMAGE + declare cmd="tags:deploy" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" IMAGE_TAG="$2" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$APP" - IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")" + local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")" verify_image "$IMAGE" || return 1 release_and_deploy "$APP" "$IMAGE_TAG" diff --git a/plugins/tags/subcommands/destroy b/plugins/tags/subcommands/destroy index d60dd6a57..7a935948e 100755 --- a/plugins/tags/subcommands/destroy +++ b/plugins/tags/subcommands/destroy @@ -6,13 +6,14 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" cmd-tags-destroy() { declare desc="destroys an app image tag via command line" - local cmd="tags:destroy" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - local APP="$2" - local IMAGE_TAG="$3" - local IMAGE_REPO=$(get_app_image_repo "$APP") - verify_app_name "$2" + declare cmd="tags:destroy" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" IMAGE_TAG="$2" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$APP" + + local IMAGE_REPO=$(get_app_image_repo "$APP") case "$IMAGE_TAG" in latest) dokku_log_fail "You can't remove internal dokku tag ($IMAGE_TAG) for $IMAGE_REPO" diff --git a/plugins/tar/functions b/plugins/tar/functions index 82887d14b..a5b703d19 100755 --- a/plugins/tar/functions +++ b/plugins/tar/functions @@ -58,21 +58,23 @@ tar_trigger_build() { cmd-tar-in() { declare desc="deploys app from tarball on STDIN via command line" - local cmd="tar:in" - local APP="$2" + declare cmd="tar:in" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" - verify_app_name "$2" + verify_app_name "$APP" tee "$DOKKU_ROOT/$APP/src.tar" | wc -c tar_receive_app "$APP" } cmd-tar-from() { declare desc="deploys app from tarball at URL via command line" - local cmd="tar:from" - verify_app_name "$2" - local APP=$2 - local URL=$3 - shift 3 + declare cmd="tar:from" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" URL="$2" + + verify_app_name "$APP" + shift 2 curl -# --insecure -L "$URL" | tar_in_cmd "tar:in" "$APP" "$@" } diff --git a/plugins/trace/subcommands/default b/plugins/trace/subcommands/default index a38c81bd6..577c44312 100755 --- a/plugins/trace/subcommands/default +++ b/plugins/trace/subcommands/default @@ -5,20 +5,23 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-trace-default() { declare desc="enables/disables trace mode" - local cmd="trace" + declare cmd="trace" + [[ "$1" == "$cmd" ]] && shift 1 + declare ARGUMENT="$1" + [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc" - [[ "$2" == "on" ]] || [[ "$2" == "off" ]] || { + [[ "$ARGUMENT" == "on" ]] || [[ "$ARGUMENT" == "off" ]] || { dokku_log_fail "Valid trace options are [on/off]" } dokku_log_warn "Deprecated: Please use trace:on or trace:off" - if [[ "$2" == "on" ]]; then + if [[ "$ARGUMENT" == "on" ]]; then dokku_log_info1 "Enabling trace mode" echo "export DOKKU_TRACE=1" >"$DOKKU_ROOT/.dokkurc/DOKKU_TRACE" fi - if [[ "$2" == "off" ]]; then + if [[ "$ARGUMENT" == "off" ]]; then dokku_log_info1 "Disabling trace mode" rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_TRACE" fi diff --git a/plugins/trace/subcommands/off b/plugins/trace/subcommands/off index 54c4bc718..51b480582 100755 --- a/plugins/trace/subcommands/off +++ b/plugins/trace/subcommands/off @@ -5,10 +5,11 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-trace-off() { declare desc="disables trace mode" - local cmd="trace" - [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc" + declare cmd="trace" + [[ "$1" == "$cmd" ]] && shift 1 dokku_log_info1 "Disabling trace mode" + [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc" rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_TRACE" } diff --git a/plugins/trace/subcommands/on b/plugins/trace/subcommands/on index 568b2dfba..aff884cff 100755 --- a/plugins/trace/subcommands/on +++ b/plugins/trace/subcommands/on @@ -5,10 +5,11 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cmd-trace-on() { declare desc="enables trace mode" - local cmd="trace" - [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc" + declare cmd="trace" + [[ "$1" == "$cmd" ]] && shift 1 dokku_log_info1 "Enabling trace mode" + [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc" echo "export DOKKU_TRACE=1" >"$DOKKU_ROOT/.dokkurc/DOKKU_TRACE" }