From 1cb586b2e7ebd0b508b738e8139b00b8dd7a0812 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 9 Feb 2020 22:41:39 -0500 Subject: [PATCH 01/11] refactor: standardize command naming This standardization makes it somewhat easier to read stacktraces as the command names are all uniform, so it will be slightly easier to scan trace output. --- docs/development/plugin-creation.md | 8 ++++---- plugins/00_dokku-standard/subcommands/cleanup | 4 ++-- plugins/00_dokku-standard/subcommands/deploy | 2 +- plugins/00_dokku-standard/subcommands/report | 4 ++-- plugins/00_dokku-standard/subcommands/run | 4 ++-- plugins/00_dokku-standard/subcommands/urls | 4 ++-- plugins/20_events/subcommands/default | 4 ++-- plugins/20_events/subcommands/list | 4 ++-- plugins/20_events/subcommands/off | 4 ++-- plugins/20_events/subcommands/on | 4 ++-- plugins/apps/commands | 2 +- plugins/apps/internal-functions | 4 ++-- plugins/apps/subcommands/clone | 4 ++-- plugins/apps/subcommands/create | 4 ++-- plugins/apps/subcommands/default | 2 +- plugins/apps/subcommands/destroy | 4 ++-- plugins/apps/subcommands/exists | 4 ++-- plugins/apps/subcommands/list | 2 +- plugins/apps/subcommands/lock | 4 ++-- plugins/apps/subcommands/locked | 4 ++-- plugins/apps/subcommands/rename | 4 ++-- plugins/apps/subcommands/unlock | 4 ++-- plugins/certs/commands | 2 +- plugins/certs/internal-functions | 4 ++-- plugins/certs/subcommands/add | 4 ++-- plugins/certs/subcommands/default | 2 +- plugins/certs/subcommands/generate | 4 ++-- plugins/certs/subcommands/info | 2 +- plugins/certs/subcommands/remove | 4 ++-- plugins/checks/commands | 2 +- plugins/checks/internal-functions | 2 +- plugins/checks/subcommands/default | 4 ++-- plugins/checks/subcommands/disable | 4 ++-- plugins/checks/subcommands/enable | 4 ++-- plugins/checks/subcommands/run | 4 ++-- plugins/checks/subcommands/skip | 4 ++-- plugins/common/functions | 4 ++-- plugins/docker-options/commands | 4 ++-- plugins/docker-options/subcommands/add | 4 ++-- plugins/docker-options/subcommands/default | 4 ++-- plugins/docker-options/subcommands/remove | 4 ++-- plugins/domains/commands | 2 +- plugins/domains/internal-functions | 2 +- plugins/domains/subcommands/add | 4 ++-- plugins/domains/subcommands/add-global | 4 ++-- plugins/domains/subcommands/clear | 4 ++-- plugins/domains/subcommands/clear-global | 4 ++-- plugins/domains/subcommands/default | 4 ++-- plugins/domains/subcommands/disable | 4 ++-- plugins/domains/subcommands/enable | 4 ++-- plugins/domains/subcommands/remove | 4 ++-- plugins/domains/subcommands/remove-global | 4 ++-- plugins/domains/subcommands/set | 4 ++-- plugins/domains/subcommands/set-global | 4 ++-- plugins/domains/subcommands/setup | 4 ++-- plugins/enter/subcommands/default | 4 ++-- plugins/git/commands | 6 +++--- plugins/git/functions | 6 +++--- plugins/git/subcommands/initialize | 4 ++-- plugins/git/subcommands/set | 4 ++-- plugins/logs/subcommands/default | 4 ++-- plugins/nginx-vhosts/commands | 2 +- plugins/nginx-vhosts/internal-functions | 2 +- plugins/nginx-vhosts/subcommands/access-logs | 4 ++-- plugins/nginx-vhosts/subcommands/build-config | 4 ++-- plugins/nginx-vhosts/subcommands/default | 2 +- plugins/nginx-vhosts/subcommands/set | 4 ++-- plugins/nginx-vhosts/subcommands/show-conf | 4 ++-- plugins/nginx-vhosts/subcommands/validate | 4 ++-- plugins/plugin/internal-functions | 2 +- plugins/plugin/subcommands/default | 2 +- plugins/plugin/subcommands/disable | 4 ++-- plugins/plugin/subcommands/enable | 4 ++-- plugins/plugin/subcommands/install | 4 ++-- plugins/plugin/subcommands/install-dependencies | 4 ++-- plugins/plugin/subcommands/list | 2 +- plugins/plugin/subcommands/trigger | 4 ++-- plugins/plugin/subcommands/uninstall | 4 ++-- plugins/plugin/subcommands/update | 4 ++-- plugins/proxy/commands | 2 +- plugins/proxy/internal-functions | 2 +- plugins/proxy/subcommands/default | 4 ++-- plugins/proxy/subcommands/disable | 4 ++-- plugins/proxy/subcommands/enable | 4 ++-- plugins/proxy/subcommands/ports | 4 ++-- plugins/proxy/subcommands/ports-add | 4 ++-- plugins/proxy/subcommands/ports-clear | 4 ++-- plugins/proxy/subcommands/ports-remove | 4 ++-- plugins/proxy/subcommands/ports-set | 4 ++-- plugins/proxy/subcommands/set | 4 ++-- plugins/ps/subcommands/default | 4 ++-- plugins/ps/subcommands/rebuild | 4 ++-- plugins/ps/subcommands/rebuildall | 4 ++-- plugins/ps/subcommands/restart | 4 ++-- plugins/ps/subcommands/restart-policy | 4 ++-- plugins/ps/subcommands/restartall | 4 ++-- plugins/ps/subcommands/restore | 4 ++-- plugins/ps/subcommands/retire | 4 ++-- plugins/ps/subcommands/scale | 4 ++-- plugins/ps/subcommands/set-restart-policy | 4 ++-- plugins/ps/subcommands/start | 4 ++-- plugins/ps/subcommands/startall | 4 ++-- plugins/ps/subcommands/stop | 4 ++-- plugins/ps/subcommands/stopall | 4 ++-- plugins/scheduler-docker-local/subcommands/set | 4 ++-- plugins/shell/subcommands/default | 4 ++-- plugins/ssh-keys/commands | 2 +- plugins/ssh-keys/functions | 7 ------- plugins/ssh-keys/internal-functions | 10 +++++++++- plugins/ssh-keys/subcommands/add | 4 ++-- plugins/ssh-keys/subcommands/default | 2 +- plugins/ssh-keys/subcommands/list | 4 ++-- plugins/ssh-keys/subcommands/remove | 4 ++-- plugins/storage/commands | 2 +- plugins/storage/internal-functions | 4 ++-- plugins/storage/subcommands/default | 2 +- plugins/storage/subcommands/list | 2 +- plugins/storage/subcommands/mount | 4 ++-- plugins/storage/subcommands/unmount | 4 ++-- plugins/tags/subcommands/create | 4 ++-- plugins/tags/subcommands/default | 4 ++-- plugins/tags/subcommands/deploy | 4 ++-- plugins/tags/subcommands/destroy | 4 ++-- plugins/tar/commands | 2 +- plugins/tar/functions | 4 ++-- plugins/tar/internal-functions | 2 +- plugins/tar/subcommands/default | 2 +- plugins/tar/subcommands/from | 2 +- plugins/tar/subcommands/in | 2 +- plugins/trace/commands | 2 +- plugins/trace/internal-functions | 2 +- plugins/trace/subcommands/default | 4 ++-- plugins/trace/subcommands/off | 4 ++-- plugins/trace/subcommands/on | 4 ++-- 134 files changed, 246 insertions(+), 245 deletions(-) diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 162389ac1..77c240dcf 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -233,7 +233,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -hello_main_cmd() { +cmd-hello-default() { declare desc="prints Hello \$APP" declare cmd="hello" argv=("$@") [[ ${argv[0]} == "$cmd" ]] && shift 1 @@ -250,7 +250,7 @@ hello_main_cmd() { echo "Hello $APP" } -hello_main_cmd "$@" +cmd-hello-default "$@" ``` `hello/subcommands/world` @@ -261,7 +261,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -hello_world_cmd() { +cmd-hello-world() { declare desc="prints Hello world" declare cmd="hello:world" argv=("$@") [[ ${argv[0]} == "$cmd" ]] && shift 1 @@ -269,7 +269,7 @@ hello_world_cmd() { echo "Hello world" } -hello_world_cmd "$@" +cmd-hello-world "$@" ``` `hello/commands` diff --git a/plugins/00_dokku-standard/subcommands/cleanup b/plugins/00_dokku-standard/subcommands/cleanup index 766089a44..42918a2b4 100755 --- a/plugins/00_dokku-standard/subcommands/cleanup +++ b/plugins/00_dokku-standard/subcommands/cleanup @@ -3,7 +3,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -dokku_cleanup_cmd() { +cmd-cleanup() { declare desc="cleans up old deployment cruft" declare cmd="cleanup" [[ "$1" == "$cmd" ]] && shift 1 @@ -16,4 +16,4 @@ dokku_cleanup_cmd() { docker_cleanup "$APP" "true" } -dokku_cleanup_cmd "$@" +cmd-cleanup "$@" diff --git a/plugins/00_dokku-standard/subcommands/deploy b/plugins/00_dokku-standard/subcommands/deploy index 4d5fae244..d49bc9e3b 100755 --- a/plugins/00_dokku-standard/subcommands/deploy +++ b/plugins/00_dokku-standard/subcommands/deploy @@ -4,4 +4,4 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" shift 1 -dokku_deploy_cmd "$@" +cmd-deploy "$@" diff --git a/plugins/00_dokku-standard/subcommands/report b/plugins/00_dokku-standard/subcommands/report index a8751baf3..67a29e175 100755 --- a/plugins/00_dokku-standard/subcommands/report +++ b/plugins/00_dokku-standard/subcommands/report @@ -3,7 +3,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -dokku_report_cmd() { +cmd-report() { declare desc="reports dokku vitals for troubleshooting" local cmd="report" declare APP="$2" @@ -31,4 +31,4 @@ dokku_report_cmd() { fi } -dokku_report_cmd "$@" +cmd-report "$@" diff --git a/plugins/00_dokku-standard/subcommands/run b/plugins/00_dokku-standard/subcommands/run index 22b87748c..e7a82c1df 100755 --- a/plugins/00_dokku-standard/subcommands/run +++ b/plugins/00_dokku-standard/subcommands/run @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -dokku_run_cmd() { +cmd-run() { declare desc="runs command in container based on app image" declare cmd="run" APP="" shift @@ -40,4 +40,4 @@ dokku_run_cmd() { plugn trigger scheduler-run "$DOKKU_SCHEDULER" "$APP" "${#RUN_ENV[@]}" "${RUN_ENV[@]}" "$@" } -dokku_run_cmd "$@" +cmd-run "$@" diff --git a/plugins/00_dokku-standard/subcommands/urls b/plugins/00_dokku-standard/subcommands/urls index eaee51564..8a2be2cbe 100755 --- a/plugins/00_dokku-standard/subcommands/urls +++ b/plugins/00_dokku-standard/subcommands/urls @@ -3,11 +3,11 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -dokku_urls_cmd() { +cmd-urls() { [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" local APP="$2" get_app_urls "$@" } -dokku_urls_cmd "$@" +cmd-urls "$@" diff --git a/plugins/20_events/subcommands/default b/plugins/20_events/subcommands/default index e29c15aab..93f7e646f 100755 --- a/plugins/20_events/subcommands/default +++ b/plugins/20_events/subcommands/default @@ -3,7 +3,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -events_main_cmd() { +cmd-events-default() { declare desc="shows contents of dokku events log" local cmd="events" if [[ -f $DOKKU_EVENTS_LOGFILE ]]; then @@ -15,4 +15,4 @@ events_main_cmd() { fi } -events_main_cmd "$@" +cmd-events-default "$@" diff --git a/plugins/20_events/subcommands/list b/plugins/20_events/subcommands/list index ddfbe4ea2..2aeceb02e 100755 --- a/plugins/20_events/subcommands/list +++ b/plugins/20_events/subcommands/list @@ -3,7 +3,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -events_list_cmd() { +cmd-events-list() { declare desc="lists enabled events" local cmd="events:list" local PLUGIN_DIR="$(dirname "$0")/.." @@ -21,4 +21,4 @@ events_list_cmd() { fi } -events_list_cmd "$@" +cmd-events-list "$@" diff --git a/plugins/20_events/subcommands/off b/plugins/20_events/subcommands/off index b91273f27..6adf893d0 100755 --- a/plugins/20_events/subcommands/off +++ b/plugins/20_events/subcommands/off @@ -3,11 +3,11 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -events_off_cmd() { +cmd-events-off() { declare desc="disables dokku events logger" local cmd="events:off" echo "Disabling dokku events logger" rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS" } -events_off_cmd "$@" +cmd-events-off "$@" diff --git a/plugins/20_events/subcommands/on b/plugins/20_events/subcommands/on index 92d1ec1c6..15738c528 100755 --- a/plugins/20_events/subcommands/on +++ b/plugins/20_events/subcommands/on @@ -3,7 +3,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -events_on_cmd() { +cmd-events-on() { declare desc="enables dokku events logger" local cmd="events:on" echo "Enabling dokku events logger" @@ -11,4 +11,4 @@ events_on_cmd() { echo "export DOKKU_EVENTS=1" >"$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS" } -events_on_cmd "$@" +cmd-events-on "$@" diff --git a/plugins/apps/commands b/plugins/apps/commands index 79b1ab4ae..7bba325ec 100755 --- a/plugins/apps/commands +++ b/plugins/apps/commands @@ -6,7 +6,7 @@ set -eo pipefail case "$1" in help | apps:help) - apps_help_cmd "$@" + cmd-apps-help "$@" ;; *) diff --git a/plugins/apps/internal-functions b/plugins/apps/internal-functions index 5f92c2439..3234cf0d1 100755 --- a/plugins/apps/internal-functions +++ b/plugins/apps/internal-functions @@ -95,7 +95,7 @@ apps_help_content_func() { help_content } -apps_help_cmd() { +cmd-apps-help() { if [[ $1 == "apps:help" ]]; then echo -e 'Usage: dokku apps[:COMMAND]' echo '' @@ -119,7 +119,7 @@ help_desc fi } -apps_list_cmd() { +cmd-apps-list() { declare desc="lists all apps" local cmd="apps" local app diff --git a/plugins/apps/subcommands/clone b/plugins/apps/subcommands/clone index 8ab7ec1a3..21b405d11 100755 --- a/plugins/apps/subcommands/clone +++ b/plugins/apps/subcommands/clone @@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/apps/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -apps_clone_cmd() { +cmd-apps-clone() { declare desc="clones an app" declare cmd="apps:clone" argv=("$@") [[ ${argv[0]} == "$cmd" ]] && shift 1 @@ -56,4 +56,4 @@ apps_clone_cmd() { dokku_log_info1_quiet "Cloning $OLD_APP to $NEW_APP... done" } -apps_clone_cmd "$@" +cmd-apps-clone "$@" diff --git a/plugins/apps/subcommands/create b/plugins/apps/subcommands/create index 83d74d2d9..ca0b1783d 100755 --- a/plugins/apps/subcommands/create +++ b/plugins/apps/subcommands/create @@ -3,10 +3,10 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/apps/functions" -apps_create_cmd() { +cmd-apps-create() { declare desc="creates app via command line" local cmd="apps:create" apps_create "$2" } -apps_create_cmd "$@" +cmd-apps-create "$@" diff --git a/plugins/apps/subcommands/default b/plugins/apps/subcommands/default index 0a0014418..93dee2425 100755 --- a/plugins/apps/subcommands/default +++ b/plugins/apps/subcommands/default @@ -4,4 +4,4 @@ set -eo pipefail source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" dokku_log_warn "Deprecated: Please use apps:list" -apps_list_cmd "$@" +cmd-apps-list "$@" diff --git a/plugins/apps/subcommands/destroy b/plugins/apps/subcommands/destroy index dca12a426..1cdd0c97c 100755 --- a/plugins/apps/subcommands/destroy +++ b/plugins/apps/subcommands/destroy @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/apps/functions" -apps_destroy_cmd() { +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" @@ -14,4 +14,4 @@ apps_destroy_cmd() { apps_destroy "$APP" } -apps_destroy_cmd "$@" +cmd-apps-destroy "$@" diff --git a/plugins/apps/subcommands/exists b/plugins/apps/subcommands/exists index b5cbb4108..bb3c6b9fc 100755 --- a/plugins/apps/subcommands/exists +++ b/plugins/apps/subcommands/exists @@ -3,7 +3,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/apps/functions" -apps_exists_cmd() { +cmd-apps-exist() { declare desc="checks if an app exists" local cmd="apps:exists" [[ "$1" == "$cmd" ]] && shift 1 @@ -15,4 +15,4 @@ apps_exists_cmd() { dokku_log_info1 "App exists" } -apps_exists_cmd "$@" +cmd-apps-exist "$@" diff --git a/plugins/apps/subcommands/list b/plugins/apps/subcommands/list index 3da1d8e7b..b7832c4b7 100755 --- a/plugins/apps/subcommands/list +++ b/plugins/apps/subcommands/list @@ -3,4 +3,4 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" -apps_list_cmd "$@" +cmd-apps-list "$@" diff --git a/plugins/apps/subcommands/lock b/plugins/apps/subcommands/lock index bcbd1ce41..0905c8952 100755 --- a/plugins/apps/subcommands/lock +++ b/plugins/apps/subcommands/lock @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" -apps_lock_cmd() { +cmd-apps-lock() { declare desc="locks an app for deployment" declare cmd="apps:lock" [[ "$1" == "$cmd" ]] && shift 1 @@ -16,4 +16,4 @@ apps_lock_cmd() { dokku_log_info1 "Deploy lock created" } -apps_lock_cmd "$@" +cmd-apps-lock "$@" diff --git a/plugins/apps/subcommands/locked b/plugins/apps/subcommands/locked index ce27a2845..5d1391e13 100755 --- a/plugins/apps/subcommands/locked +++ b/plugins/apps/subcommands/locked @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" -apps_locked_cmd() { +cmd-apps-locked() { declare desc="checks if an app is locked for deployment" declare cmd="apps:locked" [[ "$1" == "$cmd" ]] && shift 1 @@ -19,4 +19,4 @@ apps_locked_cmd() { dokku_log_quiet "Deploy lock exists" } -apps_locked_cmd "$@" +cmd-apps-locked "$@" diff --git a/plugins/apps/subcommands/rename b/plugins/apps/subcommands/rename index ed94cb1dc..1cd5a2f28 100755 --- a/plugins/apps/subcommands/rename +++ b/plugins/apps/subcommands/rename @@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/apps/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -apps_rename_cmd() { +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" @@ -34,4 +34,4 @@ apps_rename_cmd() { echo "Renaming $OLD_APP to $NEW_APP... done" } -apps_rename_cmd "$@" +cmd-apps-rename "$@" diff --git a/plugins/apps/subcommands/unlock b/plugins/apps/subcommands/unlock index fa3f95e06..eba5a1fcf 100755 --- a/plugins/apps/subcommands/unlock +++ b/plugins/apps/subcommands/unlock @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" -apps_unlock_cmd() { +cmd-apps-unlock() { declare desc="unlocks an app for deployment" declare cmd="apps:unlock" [[ "$1" == "$cmd" ]] && shift 1 @@ -21,4 +21,4 @@ apps_unlock_cmd() { dokku_log_info1 "Deploy lock removed" } -apps_unlock_cmd "$@" +cmd-apps-unlock "$@" diff --git a/plugins/certs/commands b/plugins/certs/commands index 17fa444fc..45ba33e1a 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -6,7 +6,7 @@ set -eo pipefail case "$1" in help | certs:help) - certs_help_cmd "$@" + cmd-certs-help "$@" ;; *) diff --git a/plugins/certs/internal-functions b/plugins/certs/internal-functions index b6ae228e0..a3aed6a95 100755 --- a/plugins/certs/internal-functions +++ b/plugins/certs/internal-functions @@ -87,7 +87,7 @@ certs_help_content_func() { help_content } -certs_help_cmd() { +cmd-certs-help() { if [[ $1 == "certs:help" ]]; then echo -e 'Usage: dokku certs[:COMMAND]' echo '' @@ -104,7 +104,7 @@ help_desc fi } -certs_info_cmd() { +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" diff --git a/plugins/certs/subcommands/add b/plugins/certs/subcommands/add index fcf8425c3..5d0a084e4 100755 --- a/plugins/certs/subcommands/add +++ b/plugins/certs/subcommands/add @@ -28,7 +28,7 @@ is_file_import() { return 1 } -certs_set() { +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" @@ -79,4 +79,4 @@ certs_set() { plugn trigger post-domains-update "$APP" } -certs_set "$@" +cmd-certs-set "$@" diff --git a/plugins/certs/subcommands/default b/plugins/certs/subcommands/default index 44aa722dd..5939039d9 100755 --- a/plugins/certs/subcommands/default +++ b/plugins/certs/subcommands/default @@ -4,4 +4,4 @@ set -eo pipefail source "$PLUGIN_AVAILABLE_PATH/certs/internal-functions" dokku_log_warn "Deprecated: Please use certs:report" -certs_info_cmd "$@" +cmd-certs-info "$@" diff --git a/plugins/certs/subcommands/generate b/plugins/certs/subcommands/generate index 4d691bce3..bb6ee7099 100755 --- a/plugins/certs/subcommands/generate +++ b/plugins/certs/subcommands/generate @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -certs_generate_cmd() { +cmd-certs-generate() { declare desc="generates a self-signed SSL certificate/key combo" declare APP="$2" DOMAIN="$3" local cmd="certs:generate" @@ -37,4 +37,4 @@ certs_generate_cmd() { fi } -certs_generate_cmd "$@" +cmd-certs-generate "$@" diff --git a/plugins/certs/subcommands/info b/plugins/certs/subcommands/info index 44aa722dd..5939039d9 100755 --- a/plugins/certs/subcommands/info +++ b/plugins/certs/subcommands/info @@ -4,4 +4,4 @@ set -eo pipefail source "$PLUGIN_AVAILABLE_PATH/certs/internal-functions" dokku_log_warn "Deprecated: Please use certs:report" -certs_info_cmd "$@" +cmd-certs-info "$@" diff --git a/plugins/certs/subcommands/remove b/plugins/certs/subcommands/remove index aeb2235ec..ac6b02bf2 100755 --- a/plugins/certs/subcommands/remove +++ b/plugins/certs/subcommands/remove @@ -3,7 +3,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -certs_remove_cmd() { +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" @@ -21,4 +21,4 @@ certs_remove_cmd() { fi } -certs_remove_cmd "$@" +cmd-certs-remove "$@" diff --git a/plugins/checks/commands b/plugins/checks/commands index 850cb9e97..8889968d3 100755 --- a/plugins/checks/commands +++ b/plugins/checks/commands @@ -6,7 +6,7 @@ set -eo pipefail case "$1" in help | checks:help) - checks_help_cmd "$@" + cmd-checks-help "$@" ;; *) diff --git a/plugins/checks/internal-functions b/plugins/checks/internal-functions index 55ea99c69..58ff9a150 100755 --- a/plugins/checks/internal-functions +++ b/plugins/checks/internal-functions @@ -77,7 +77,7 @@ checks_help_content_func() { help_content } -checks_help_cmd() { +cmd-checks-help() { if [[ $1 == "checks:help" ]]; then echo -e 'Usage: dokku checks[:COMMAND]' echo '' diff --git a/plugins/checks/subcommands/default b/plugins/checks/subcommands/default index 5f99e8f1b..8c4b0f876 100755 --- a/plugins/checks/subcommands/default +++ b/plugins/checks/subcommands/default @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/checks/functions" -checks_main_cmd() { +cmd-checks-default() { declare desc="displays app zero-downtime checks status" local cmd="checks" [[ "$1" == "$cmd" ]] && shift 1 @@ -26,4 +26,4 @@ checks_main_cmd() { done } -checks_main_cmd "$@" +cmd-checks-default "$@" diff --git a/plugins/checks/subcommands/disable b/plugins/checks/subcommands/disable index 0ae59bba7..85b7aae58 100755 --- a/plugins/checks/subcommands/disable +++ b/plugins/checks/subcommands/disable @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/checks/functions" -checks_disable_cmd() { +cmd-checks-disable() { declare desc="disable zero-downtime checks for app/proctypes" local cmd="checks:disable" [[ "$1" == "$cmd" ]] && shift 1 @@ -43,4 +43,4 @@ checks_disable_cmd() { fi } -checks_disable_cmd "$@" +cmd-checks-disable "$@" diff --git a/plugins/checks/subcommands/enable b/plugins/checks/subcommands/enable index 59e2974b9..3db35d07e 100755 --- a/plugins/checks/subcommands/enable +++ b/plugins/checks/subcommands/enable @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/checks/functions" -checks_enable_cmd() { +cmd-checks-enable() { declare desc="enable zero-downtime checks for app/proctypes" local cmd="checks:enable" [[ "$1" == "$cmd" ]] && shift 1 @@ -42,4 +42,4 @@ checks_enable_cmd() { fi } -checks_enable_cmd "$@" +cmd-checks-enable "$@" diff --git a/plugins/checks/subcommands/run b/plugins/checks/subcommands/run index 892268cbf..fb50a8d34 100755 --- a/plugins/checks/subcommands/run +++ b/plugins/checks/subcommands/run @@ -67,7 +67,7 @@ check_process() { plugn trigger check-deploy "$APP" "$CONTAINER_ID" "$PROC_TYPE" "$PORT" "$IP" } -checks_run_cmd() { +cmd-checks-run() { declare desc="run zero-downtime checks for app/proctypes" local cmd="checks:run" [[ "$1" == "$cmd" ]] && shift 1 @@ -94,4 +94,4 @@ checks_run_cmd() { fi } -checks_run_cmd "$@" +cmd-checks-run "$@" diff --git a/plugins/checks/subcommands/skip b/plugins/checks/subcommands/skip index 169307c8c..8c3e57137 100755 --- a/plugins/checks/subcommands/skip +++ b/plugins/checks/subcommands/skip @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/checks/functions" -checks_skip_cmd() { +cmd-checks-skip() { declare desc="skip zero-downtime checks for app/proctypes" local cmd="checks:skip" [[ "$1" == "$cmd" ]] && shift 1 @@ -43,4 +43,4 @@ checks_skip_cmd() { fi } -checks_skip_cmd "$@" +cmd-checks-skip "$@" diff --git a/plugins/common/functions b/plugins/common/functions index 592cc2e9c..ddb074bde 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -571,7 +571,7 @@ dokku_release() { plugn trigger builder-release "$IMAGE_SOURCE_TYPE" "$APP" "$IMAGE_TAG" } -dokku_deploy_cmd() { +cmd-deploy() { declare desc="deploy phase" declare APP="$1" IMAGE_TAG="$2" source "$PLUGIN_AVAILABLE_PATH/config/functions" @@ -613,7 +613,7 @@ release_and_deploy() { if [[ "$DOKKU_SKIP_DEPLOY" != "true" ]]; then dokku_log_info1 "Deploying $APP ($IMAGE)..." - dokku_deploy_cmd "$APP" "$IMAGE_TAG" + cmd-deploy "$APP" "$IMAGE_TAG" dokku_log_info2 "Application deployed:" get_app_urls urls "$APP" | sed "s/^/ /" else diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index b29fbd6ef..fdcf24568 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -14,7 +14,7 @@ docker_options_help_content_func() { help_content } -docker_options_help_cmd() { +cmd-docker-options-help() { if [[ $1 == "docker-options:help" ]]; then echo -e 'Usage: dokku docker-options[:COMMAND]' echo '' @@ -33,7 +33,7 @@ help_desc case "$1" in help | docker-options:help) - docker_options_help_cmd "$@" + cmd-docker-options-help "$@" ;; *) diff --git a/plugins/docker-options/subcommands/add b/plugins/docker-options/subcommands/add index 72d64129c..799c9831e 100755 --- a/plugins/docker-options/subcommands/add +++ b/plugins/docker-options/subcommands/add @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" -docker_options_add_cmd() { +cmd-docker-options-add() { declare desc="Add a docker option to application" local cmd="docker-options:add" @@ -16,4 +16,4 @@ docker_options_add_cmd() { add_passed_docker_option passed_phases[@] "${passed_docker_option[@]}" } -docker_options_add_cmd "$@" +cmd-docker-options-add "$@" diff --git a/plugins/docker-options/subcommands/default b/plugins/docker-options/subcommands/default index 8032e9a84..9ffe4fe01 100755 --- a/plugins/docker-options/subcommands/default +++ b/plugins/docker-options/subcommands/default @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" -docker_options_main_cmd() { +cmd-docker-options-default() { declare desc="Display applications docker options" local cmd="docker-options" dokku_log_warn "Deprecated: Please use docker-options:report" @@ -18,4 +18,4 @@ docker_options_main_cmd() { fi } -docker_options_main_cmd "$@" +cmd-docker-options-default "$@" diff --git a/plugins/docker-options/subcommands/remove b/plugins/docker-options/subcommands/remove index d63be3822..a57a8080d 100755 --- a/plugins/docker-options/subcommands/remove +++ b/plugins/docker-options/subcommands/remove @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" -docker_options_remove_cmd() { +cmd-docker-options-remove() { declare desc="Remove a docker option from application" local cmd="docker-options:remove" @@ -16,4 +16,4 @@ docker_options_remove_cmd() { remove_passed_docker_option passed_phases[@] "${passed_docker_option[@]}" } -docker_options_remove_cmd "$@" +cmd-docker-options-remove "$@" diff --git a/plugins/domains/commands b/plugins/domains/commands index 328664b40..695b00b66 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -6,7 +6,7 @@ set -eo pipefail case "$1" in help | domains:help) - domains_help_cmd "$@" + cmd-domains-help "$@" ;; *) diff --git a/plugins/domains/internal-functions b/plugins/domains/internal-functions index 8da721b64..89af4f890 100755 --- a/plugins/domains/internal-functions +++ b/plugins/domains/internal-functions @@ -102,7 +102,7 @@ domains_help_content_func() { help_content } -domains_help_cmd() { +cmd-domains-help() { if [[ $1 == "domains:help" ]]; then echo -e 'Usage: dokku domains[:COMMAND]' echo '' diff --git a/plugins/domains/subcommands/add b/plugins/domains/subcommands/add index 382976691..e8e8cd5b9 100755 --- a/plugins/domains/subcommands/add +++ b/plugins/domains/subcommands/add @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_add_cmd() { +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" @@ -14,4 +14,4 @@ domains_add_cmd() { domains_add "$@" } -domains_add_cmd "$@" +cmd-domains-add "$@" diff --git a/plugins/domains/subcommands/add-global b/plugins/domains/subcommands/add-global index c58eed710..4ccf1b825 100755 --- a/plugins/domains/subcommands/add-global +++ b/plugins/domains/subcommands/add-global @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_add_global_cmd() { +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 [ ...]" @@ -13,4 +13,4 @@ domains_add_global_cmd() { domains_add_global "$@" } -domains_add_global_cmd "$@" +cmd-domains-add-global "$@" diff --git a/plugins/domains/subcommands/clear b/plugins/domains/subcommands/clear index 1ea9a4b19..759c132a2 100755 --- a/plugins/domains/subcommands/clear +++ b/plugins/domains/subcommands/clear @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_clear_cmd() { +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" @@ -18,4 +18,4 @@ domains_clear_cmd() { dokku_log_info1 "Cleared domains in $APP" } -domains_clear_cmd "$@" +cmd-domains-clear "$@" diff --git a/plugins/domains/subcommands/clear-global b/plugins/domains/subcommands/clear-global index 42ce3ee30..9024a6430 100755 --- a/plugins/domains/subcommands/clear-global +++ b/plugins/domains/subcommands/clear-global @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_clear_global_cmd() { +cmd-domains-clear-global() { declare desc="clear global domain names via command line" local cmd="domains:clear-global" shift 1 @@ -13,4 +13,4 @@ domains_clear_global_cmd() { domains_clear_global "$@" } -domains_clear_global_cmd "$@" +cmd-domains-clear-global "$@" diff --git a/plugins/domains/subcommands/default b/plugins/domains/subcommands/default index 6930e6b52..6b9650fa1 100755 --- a/plugins/domains/subcommands/default +++ b/plugins/domains/subcommands/default @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_main_cmd() { +cmd-domains-default() { declare desc="print app domains" local cmd="domains" local APP="$2" @@ -30,4 +30,4 @@ domains_main_cmd() { fi } -domains_main_cmd "$@" +cmd-domains-default "$@" diff --git a/plugins/domains/subcommands/disable b/plugins/domains/subcommands/disable index 1a5e469e6..224176e30 100755 --- a/plugins/domains/subcommands/disable +++ b/plugins/domains/subcommands/disable @@ -4,11 +4,11 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_disable_cmd() { +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" } -domains_disable_cmd "$@" +cmd-domains-disable "$@" diff --git a/plugins/domains/subcommands/enable b/plugins/domains/subcommands/enable index 8253f6a64..5cb4d10da 100755 --- a/plugins/domains/subcommands/enable +++ b/plugins/domains/subcommands/enable @@ -4,11 +4,11 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_enable_cmd() { +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" } -domains_enable_cmd "$@" +cmd-domains-enable "$@" diff --git a/plugins/domains/subcommands/remove b/plugins/domains/subcommands/remove index 2d6127cb9..0eaf71cf1 100755 --- a/plugins/domains/subcommands/remove +++ b/plugins/domains/subcommands/remove @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_remove_cmd() { +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" @@ -14,4 +14,4 @@ domains_remove_cmd() { domains_remove "$@" } -domains_remove_cmd "$@" +cmd-domains-remove "$@" diff --git a/plugins/domains/subcommands/remove-global b/plugins/domains/subcommands/remove-global index b9bba0d0f..574184392 100755 --- a/plugins/domains/subcommands/remove-global +++ b/plugins/domains/subcommands/remove-global @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_remove_global_cmd() { +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 [ ...]" @@ -13,4 +13,4 @@ domains_remove_global_cmd() { domains_remove_global "$@" } -domains_remove_global_cmd "$@" +cmd-domains-remove-global "$@" diff --git a/plugins/domains/subcommands/set b/plugins/domains/subcommands/set index c61dd4c94..2b8ace952 100755 --- a/plugins/domains/subcommands/set +++ b/plugins/domains/subcommands/set @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_set_cmd() { +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" @@ -14,4 +14,4 @@ domains_set_cmd() { domains_set "$@" } -domains_set_cmd "$@" +cmd-domains-set "$@" diff --git a/plugins/domains/subcommands/set-global b/plugins/domains/subcommands/set-global index 94ea71e72..88f9a5c99 100755 --- a/plugins/domains/subcommands/set-global +++ b/plugins/domains/subcommands/set-global @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_set_global_cmd() { +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 [ ...]" @@ -13,4 +13,4 @@ domains_set_global_cmd() { domains_set_global "$@" } -domains_set_global_cmd "$@" +cmd-domains-set-global "$@" diff --git a/plugins/domains/subcommands/setup b/plugins/domains/subcommands/setup index b51169582..57be41235 100755 --- a/plugins/domains/subcommands/setup +++ b/plugins/domains/subcommands/setup @@ -4,11 +4,11 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -domains_setup_cmd() { +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" } -domains_setup_cmd "$@" +cmd-domains-setup "$@" diff --git a/plugins/enter/subcommands/default b/plugins/enter/subcommands/default index 10b7a2402..397457197 100755 --- a/plugins/enter/subcommands/default +++ b/plugins/enter/subcommands/default @@ -4,7 +4,7 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -enter_default_cmd() { +cmd-enter-default() { declare desc="enters running app container of specified proc type" local cmd="enter" local APP="$2" @@ -63,4 +63,4 @@ enter_default_cmd() { "$DOCKER_BIN" container exec $DOKKU_RUN_OPTS $ID $EXEC_CMD "${@:-$DOKKU_APP_SHELL}" } -enter_default_cmd "$@" +cmd-enter-default "$@" diff --git a/plugins/git/commands b/plugins/git/commands index 654cbcc98..365d6f65a 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -6,15 +6,15 @@ source "$PLUGIN_AVAILABLE_PATH/git/internal-functions" case "$1" in git-hook) - git_hook_cmd "$@" + cmd-git-hook "$@" ;; git-upload-pack) - git_upload_pack_cmd "$@" + cmd-git-upload-pack "$@" ;; git-*) - git_glob_cmd "$@" + cmd-git-glob "$@" ;; help | git:help) diff --git a/plugins/git/functions b/plugins/git/functions index db4ab4837..123b0e6a9 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -123,7 +123,7 @@ git_deploy_branch() { fi } -git_hook_cmd() { +cmd-git-hook() { declare desc="kick off receive-app trigger from git prereceive hook" local cmd="git-hook" local APP="$2" @@ -195,7 +195,7 @@ git_receive_app() { fi } -git_upload_pack_cmd() { +cmd-git-upload-pack() { declare desc="executes git-upload-pack" declare cmd="git-upload-pack" declare APP="$2" @@ -208,7 +208,7 @@ git_upload_pack_cmd() { plugn trigger git-post-pull "$APP" } -git_glob_cmd() { +cmd-git-glob() { declare desc="catch-all for any other git-* commands" local cmd="git-*" local APP="$(echo "$2" | perl -pe 's/(?"$DOKKU_ROOT/.dokkurc/DOKKU_TRACE" } -trace_on_cmd "$@" +cmd-trace-on "$@" From be5ea845fcd2911ef501faa7c346b7fb3f625c6b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 9 Feb 2020 22:43:34 -0500 Subject: [PATCH 02/11] fix: clean prop bin as well during make clean --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 0b766a356..f4ce217db 100644 --- a/common.mk +++ b/common.mk @@ -17,7 +17,7 @@ build-in-docker: clean bash -c "GO_ARGS='$(GO_ARGS)' make -j4 build" || exit $$? clean: - rm -rf commands subcommands triggers + rm -rf commands subcommands triggers prop find . -xtype l -delete commands: **/**/commands.go From ef7894fdfa3e974f9a09717613ce6e13c8e4ca53 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 00:37:00 -0500 Subject: [PATCH 03/11] refactor: standardize help generation --- plugins/00_dokku-standard/commands | 24 ++-------- plugins/00_dokku-standard/help-functions | 27 +++++++++++ plugins/20_events/commands | 22 +-------- plugins/20_events/help-functions | 35 ++++++++++++++ plugins/20_events/subcommands/list | 3 ++ plugins/apps/commands | 2 +- plugins/apps/help-functions | 42 +++++++++++++++++ plugins/apps/internal-functions | 41 ----------------- plugins/buildpacks/src/commands/commands.go | 4 +- plugins/certs/commands | 2 +- plugins/certs/help-functions | 41 +++++++++++++++++ plugins/certs/internal-functions | 33 ------------- plugins/checks/commands | 2 +- plugins/checks/help-functions | 37 +++++++++++++++ plugins/checks/internal-functions | 29 ------------ plugins/config/src/commands/commands.go | 6 +-- plugins/docker-options/commands | 29 +----------- plugins/docker-options/help-functions | 36 +++++++++++++++ plugins/domains/commands | 2 +- plugins/domains/help-functions | 43 +++++++++++++++++ plugins/domains/internal-functions | 35 -------------- plugins/enter/commands | 19 +------- plugins/enter/help-functions | 32 +++++++++++++ plugins/git/commands | 1 + plugins/git/help-functions | 34 ++++++++++++++ plugins/git/internal-functions | 27 ----------- plugins/git/subcommands/default | 2 +- plugins/logs/commands | 2 +- plugins/logs/help-functions | 33 +++++++++++++ plugins/logs/internal-functions | 25 ---------- plugins/network/src/commands/commands.go | 14 +++--- plugins/nginx-vhosts/commands | 2 +- plugins/nginx-vhosts/help-functions | 38 +++++++++++++++ plugins/nginx-vhosts/internal-functions | 30 ------------ plugins/nginx-vhosts/subcommands/default | 2 +- plugins/plugin/commands | 26 +---------- plugins/plugin/help-functions | 39 ++++++++++++++++ plugins/proxy/commands | 2 +- plugins/proxy/help-functions | 41 +++++++++++++++++ plugins/proxy/internal-functions | 33 ------------- plugins/ps/commands | 33 +------------ plugins/ps/help-functions | 46 +++++++++++++++++++ plugins/repo/src/commands/commands.go | 4 +- plugins/resource/src/commands/commands.go | 4 +- plugins/scheduler-docker-local/commands | 2 +- plugins/scheduler-docker-local/help-functions | 33 +++++++++++++ .../scheduler-docker-local/internal-functions | 26 ----------- .../subcommands/default | 2 +- plugins/shell/commands | 21 +-------- plugins/shell/help-functions | 32 +++++++++++++ plugins/ssh-keys/commands | 2 +- plugins/ssh-keys/help-functions | 34 ++++++++++++++ plugins/ssh-keys/internal-functions | 27 ----------- plugins/ssh-keys/subcommands/default | 2 +- plugins/storage/commands | 2 +- plugins/storage/help-functions | 35 ++++++++++++++ plugins/storage/internal-functions | 27 ----------- plugins/storage/subcommands/default | 2 +- plugins/tags/commands | 22 +-------- plugins/tags/help-functions | 35 ++++++++++++++ plugins/tar/commands | 4 +- plugins/tar/help-functions | 33 +++++++++++++ plugins/tar/internal-functions | 28 ----------- plugins/tar/subcommands/default | 2 +- plugins/trace/commands | 2 +- plugins/trace/help-functions | 34 ++++++++++++++ plugins/trace/internal-functions | 28 ----------- 67 files changed, 816 insertions(+), 603 deletions(-) create mode 100755 plugins/00_dokku-standard/help-functions create mode 100755 plugins/20_events/help-functions create mode 100755 plugins/apps/help-functions create mode 100755 plugins/certs/help-functions create mode 100755 plugins/checks/help-functions create mode 100755 plugins/docker-options/help-functions create mode 100755 plugins/domains/help-functions create mode 100755 plugins/enter/help-functions create mode 100755 plugins/git/help-functions create mode 100755 plugins/logs/help-functions create mode 100755 plugins/nginx-vhosts/help-functions create mode 100755 plugins/plugin/help-functions create mode 100755 plugins/proxy/help-functions create mode 100755 plugins/ps/help-functions create mode 100755 plugins/scheduler-docker-local/help-functions create mode 100755 plugins/shell/help-functions create mode 100755 plugins/ssh-keys/help-functions create mode 100755 plugins/storage/help-functions create mode 100755 plugins/tags/help-functions create mode 100755 plugins/tar/help-functions delete mode 100755 plugins/tar/internal-functions create mode 100755 plugins/trace/help-functions delete mode 100755 plugins/trace/internal-functions diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index 7e830763a..56b37905c 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -1,28 +1,12 @@ #!/usr/bin/env bash -[[ " help help:help cleanup:help run:help trace:help url:help urls:help version:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +[[ " help help:help cleanup:help run:help url:help urls:help version:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/00_dokku-standard/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in - help | cleanup:help | run:help | trace:help | url:help | urls:help | version:help) - [[ $(echo "$1" | sed '/.*:help/!d') ]] && help_topic="${1%\:help}" - help_content_func() { - declare desc="return standard plugin help content" - cat <], Cleans up exited/dead Docker containers and removes dangling images - run [--env KEY=VALUE] , Run a command in a new container using the current application image - url , Show the first URL for an application (compatibility) - urls , Show all URLs for an application - version , Print dokku's version - help , Print the list of commands -help_content - } - - if [[ $help_topic ]]; then - help_content_func | sed "/^\s*$help_topic\s/!d" | sort | sed '/^.*:/d' | column -c2 -t -s, - else - help_content_func - fi + help | cleanup:help | run:help | url:help | urls:help | version:help) + cmd-standard-help "$@" ;; *) diff --git a/plugins/00_dokku-standard/help-functions b/plugins/00_dokku-standard/help-functions new file mode 100755 index 000000000..2c8bceef3 --- /dev/null +++ b/plugins/00_dokku-standard/help-functions @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-standard-help() { + declare desc="help command" + declare CMD="$1" + + [[ $(echo "$CMD" | sed '/.*:help/!d') ]] && help_topic="${CMD%\:help}" + if [[ $help_topic ]]; then + fn-help-content | sed "/^\s*$help_topic\s/!d" | sort | sed '/^.*:/d' | column -c2 -t -s, + else + fn-help-content + fi +} + +fn-help-content() { + declare desc="return help content" + cat <], Cleans up exited/dead Docker containers and removes dangling images + run [--env KEY=VALUE] , Run a command in a new container using the current application image + url , Show the first URL for an application (compatibility) + urls , Show all URLs for an application + version , Print dokku's version + help , Print the list of commands +help_content +} diff --git a/plugins/20_events/commands b/plugins/20_events/commands index 7ed6da3cc..84e73108d 100755 --- a/plugins/20_events/commands +++ b/plugins/20_events/commands @@ -1,30 +1,12 @@ #!/usr/bin/env bash [[ " help events:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/20_events/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in help | events:help) - help_content_func() { - declare desc="return events plugin help content" - cat < , Clones an app + apps:create , Create a new app + apps:destroy , Permanently destroy an app + apps:exists , Checks if an app exists + apps:list, List your apps + apps:lock , Locks an app for deployment + apps:locked , Checks if an app is locked for deployment + apps:rename , Rename an app + apps:report [] [], Display report about an app + apps:unlock , Unlocks an app for deployment +help_content +} diff --git a/plugins/apps/internal-functions b/plugins/apps/internal-functions index 3234cf0d1..7ed59bcf6 100755 --- a/plugins/apps/internal-functions +++ b/plugins/apps/internal-functions @@ -78,47 +78,6 @@ cmd-apps-report-single() { fi } -apps_help_content_func() { - declare desc="return apps plugin help content" - cat < , Clones an app - apps:create , Create a new app - apps:destroy , Permanently destroy an app - apps:exists , Checks if an app exists - apps:list, List your apps - apps:lock , Locks an app for deployment - apps:locked , Checks if an app is locked for deployment - apps:rename , Rename an app - apps:report [] [], Display report about an app - apps:unlock , Unlocks an app for deployment -help_content -} - -cmd-apps-help() { - if [[ $1 == "apps:help" ]]; then - echo -e 'Usage: dokku apps[:COMMAND]' - echo '' - echo 'Manage Dokku apps' - echo '' - echo 'Example:' - echo '' - echo '$ dokku apps:list' - echo '=====> My Apps' - echo 'example' - echo 'example2' - echo '' - echo 'Additional commands:' - apps_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - apps_help_content_func - else - cat <, [DEPRECATED] Alternative for certs:report + certs:add CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin + certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate + certs:generate DOMAIN, Generate a key and certificate signing request (and self-signed certificate) + certs:info , [DEPRECATED] Alternative for certs:report + certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate + certs:remove , Remove an SSL Endpoint from an app + certs:report [] [], Displays an ssl report for one or more apps + certs:rollback , [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app + certs:update CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin +help_content +} diff --git a/plugins/certs/internal-functions b/plugins/certs/internal-functions index a3aed6a95..76cdeaa92 100755 --- a/plugins/certs/internal-functions +++ b/plugins/certs/internal-functions @@ -71,39 +71,6 @@ cmd-certs-report-single() { fi } -certs_help_content_func() { - declare desc="return certs plugin help content" - cat <, [DEPRECATED] Alternative for certs:report - certs:add CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin - certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate - certs:generate DOMAIN, Generate a key and certificate signing request (and self-signed certificate) - certs:info , [DEPRECATED] Alternative for certs:report - certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate - certs:remove , Remove an SSL Endpoint from an app - certs:report [] [], Displays an ssl report for one or more apps - certs:rollback , [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app - certs:update CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin -help_content -} - -cmd-certs-help() { - if [[ $1 == "certs:help" ]]; then - echo -e 'Usage: dokku certs[:COMMAND]' - echo '' - echo 'Manage Dokku apps SSL (TLS) certs.' - echo '' - echo 'Additional commands:' - certs_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - certs_help_content_func - else - cat <, [DEPRECATED] Alternative for checks:report + checks:disable [process-type(s)], Disable zero-downtime deployment for all processes (or comma-separated process-type list) ***WARNING: this will cause downtime during deployments*** + checks:enable [process-type(s)], Enable zero-downtime deployment for all processes (or comma-separated process-type list) + checks:report [] [], Displays a checks report for one or more apps + checks:run [process-type(s)], Runs zero-downtime checks for all processes (or comma-separated process-type list) + checks:skip [process-type(s)], Skip zero-downtime checks for all processes (or comma-separated process-type list) +help_content +} diff --git a/plugins/checks/internal-functions b/plugins/checks/internal-functions index 58ff9a150..75dc5d3bf 100755 --- a/plugins/checks/internal-functions +++ b/plugins/checks/internal-functions @@ -65,35 +65,6 @@ cmd-checks-report-single() { fi } -checks_help_content_func() { - declare desc="return checks plugin help content" - cat <, [DEPRECATED] Alternative for checks:report - checks:disable [process-type(s)], Disable zero-downtime deployment for all processes (or comma-separated process-type list) ***WARNING: this will cause downtime during deployments*** - checks:enable [process-type(s)], Enable zero-downtime deployment for all processes (or comma-separated process-type list) - checks:report [] [], Displays a checks report for one or more apps - checks:run [process-type(s)], Runs zero-downtime checks for all processes (or comma-separated process-type list) - checks:skip [process-type(s)], Skip zero-downtime checks for all processes (or comma-separated process-type list) -help_content -} - -cmd-checks-help() { - if [[ $1 == "checks:help" ]]; then - echo -e 'Usage: dokku checks[:COMMAND]' - echo '' - echo 'Manage zero-downtime settings.' - echo '' - echo 'Additional commands:' - checks_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - checks_help_content_func - else - cat <|--global] + helpHeader = `Usage: dokku config[:COMMAND] -Display all global or app-specific config vars +Manage global and app-specific config vars Additional commands:` @@ -55,7 +55,7 @@ func main() { if err == nil && strings.Contains(string(output), "--all") { fmt.Println(helpContent) } else { - fmt.Print("\n config, Manages global and app-specific config vars\n") + fmt.Print("\n config, Manage global and app-specific config vars\n") } default: dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT")) diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index fdcf24568..f404d4a31 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -1,36 +1,9 @@ #!/usr/bin/env bash [[ " help docker-options:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/docker-options/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -docker_options_help_content_func() { - declare desc="return docker-options plugin help content" - cat < [phase(s)], [DEPRECATED] Alternative for docker-options:report - docker-options:add OPTION, Add Docker option to app for phase (comma separated phase list) - docker-options:clear [phase(s)], Clear a docker options from application with an optional phase (comma separated phase list) - docker-options:remove OPTION, Remove Docker option from app for phase (comma separated phase list) - docker-options:report [] [], Displays a docker options report for one or more apps -help_content -} - -cmd-docker-options-help() { - if [[ $1 == "docker-options:help" ]]; then - echo -e 'Usage: dokku docker-options[:COMMAND]' - echo '' - echo 'Display app'"'"'s Docker options for all phases.' - echo '' - echo 'Additional commands:' - docker_options_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - docker_options_help_content_func - else - cat < [phase(s)], [DEPRECATED] Alternative for docker-options:report + docker-options:add OPTION, Add Docker option to app for phase (comma separated phase list) + docker-options:clear [phase(s)], Clear a docker options from application with an optional phase (comma separated phase list) + docker-options:remove OPTION, Remove Docker option from app for phase (comma separated phase list) + docker-options:report [] [], Displays a docker options report for one or more apps +help_content +} diff --git a/plugins/domains/commands b/plugins/domains/commands index 695b00b66..482fbc229 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash [[ " help domains:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" -source "$PLUGIN_AVAILABLE_PATH/domains/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/domains/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x diff --git a/plugins/domains/help-functions b/plugins/domains/help-functions new file mode 100755 index 000000000..34e565a46 --- /dev/null +++ b/plugins/domains/help-functions @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-domains-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="domains" + local plugin_description="Manage domains used by the proxy" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat <], [DEPRECATED] Alternative for domains:report + domains:add [ ...], Add domains to app + domains:add-global [ ...], Add global domain names + domains:clear , Clear all domains for app + domains:clear-global, Clear global domain names + domains:disable , Disable VHOST support + domains:enable , Enable VHOST support + domains:remove [ ...], Remove domains from app + domains:remove-global [ ...], Remove global domain names + domains:report [|--global] [], Displays a domains report for one or more apps + domains:set [ ...], Set domains for app + domains:set-global [ ...], Set global domain names +help_content +} diff --git a/plugins/domains/internal-functions b/plugins/domains/internal-functions index 89af4f890..f1d193448 100755 --- a/plugins/domains/internal-functions +++ b/plugins/domains/internal-functions @@ -84,41 +84,6 @@ cmd-domains-report-single() { fi } -domains_help_content_func() { - declare desc="return domains plugin help content" - cat <], [DEPRECATED] Alternative for domains:report - domains:add [ ...], Add domains to app - domains:add-global [ ...], Add global domain names - domains:clear , Clear all domains for app - domains:clear-global, Clear global domain names - domains:disable , Disable VHOST support - domains:enable , Enable VHOST support - domains:remove [ ...], Remove domains from app - domains:remove-global [ ...], Remove global domain names - domains:report [|--global] [], Displays a domains report for one or more apps - domains:set [ ...], Set domains for app - domains:set-global [ ...], Set global domain names -help_content -} - -cmd-domains-help() { - if [[ $1 == "domains:help" ]]; then - echo -e 'Usage: dokku domains[:COMMAND]' - echo '' - echo 'Manage vhost domains used by the Dokku proxy.' - echo '' - echo 'Additional commands:' - domains_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - domains_help_content_func - else - cat < [ || --container-id ], Connect to a specific app container -help_content - } - - if [[ $1 == "enter:help" ]]; then - echo -e 'Usage: dokku enter ' - echo '' - echo 'Allows you to access a bash prompt inside the container of the app.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + cmd-enter-help "$@" ;; *) diff --git a/plugins/enter/help-functions b/plugins/enter/help-functions new file mode 100755 index 000000000..3df2892e5 --- /dev/null +++ b/plugins/enter/help-functions @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-enter-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="enter" + local plugin_description="Enter running app containers" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat < [ || --container-id ], Connect to a specific app container +help_content +} diff --git a/plugins/git/commands b/plugins/git/commands index 365d6f65a..34afa72bd 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -3,6 +3,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/git/functions" source "$PLUGIN_AVAILABLE_PATH/git/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/git/help-functions" case "$1" in git-hook) diff --git a/plugins/git/help-functions b/plugins/git/help-functions new file mode 100755 index 000000000..f3f72bac0 --- /dev/null +++ b/plugins/git/help-functions @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-git-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="git" + local plugin_description="Manage app deploys via git" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat <, Initialize a git repository for an app + git:report [] [], Displays a git report for one or more apps + git:set (), Set or clear a git property for an app +help_content +} diff --git a/plugins/git/internal-functions b/plugins/git/internal-functions index 5f87ab0fd..b497e2516 100755 --- a/plugins/git/internal-functions +++ b/plugins/git/internal-functions @@ -66,30 +66,3 @@ cmd-git-report-single() { [[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed" fi } - -git_help_content_func() { - declare desc="return git plugin help content" - cat <, Initialize a git repository for an app - git:report [] [], Displays a git report for one or more apps - git:set (), Set or clear a git property for an app -help_content -} - -cmd-git-help() { - if [[ $1 == "git:help" ]]; then - echo -e 'Usage: dokku git[:COMMAND]' - echo '' - echo 'Manages the git integration for an app.' - echo '' - echo 'Additional commands:' - git_help_content_func | sort | column -c2 -t -s, - echo '' - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - git_help_content_func - else - cat < [-h] [-t] [-n num] [-q] [-p process], Display recent log output + logs:failed , Show the last logs for an application +help_content +} diff --git a/plugins/logs/internal-functions b/plugins/logs/internal-functions index 1a79c4159..dbefa3041 100755 --- a/plugins/logs/internal-functions +++ b/plugins/logs/internal-functions @@ -12,28 +12,3 @@ fn-logs-usage() { echo " -t, --tail # continually stream logs" echo " -q, --quiet # display raw logs without colors, time and names" } - -fn-logs-help-content() { - declare desc="return logs plugin help content" - cat < [-h] [-t] [-n num] [-q] [-p process], Display recent log output - logs:failed , Show the last logs for an application -help_content -} - -cmd-logs-help() { - if [[ $1 == "logs:help" ]]; then - echo -e 'Usage: dokku logs[:COMMAND]' - echo '' - echo 'Output app logs' - echo '' - echo 'Additional commands:' - fn-logs-help-content | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - fn-logs-help-content - else - cat <, Creates an attachable docker network - network:destroy , Destroys a docker network - network:exists , Checks if a docker network exists - network:info , Outputs information about a docker network - network:list, Lists all docker networks + network:create , Creates an attachable docker network + network:destroy , Destroys a docker network + network:exists , Checks if a docker network exists + network:info , Outputs information about a docker network + network:list, Lists all docker networks network:report [] [], Displays a network report for one or more apps network:rebuild , Rebuilds network settings for an app network:rebuildall, Rebuild network settings for all apps @@ -47,7 +47,7 @@ func main() { if err == nil && strings.Contains(string(output), "--all") { fmt.Println(helpContent) } else { - fmt.Print("\n network, Manages network settings for an app\n") + fmt.Print("\n network, Manage network settings for an app\n") } default: dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT")) diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index bc88b28a2..a9d08e243 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash [[ " help nginx:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" -source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x diff --git a/plugins/nginx-vhosts/help-functions b/plugins/nginx-vhosts/help-functions new file mode 100755 index 000000000..d8e660210 --- /dev/null +++ b/plugins/nginx-vhosts/help-functions @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-nginx-vhosts-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="nginx" + local plugin_description="Manage the nginx proxy" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat < [-t], Show the nginx access logs for an application (-t follows) + nginx:build-config , (Re)builds nginx config for given app + nginx:error-logs [-t], Show the nginx error logs for an application (-t follows) + nginx:report [] [], Displays an nginx report for one or more apps + nginx:set (), Set or clear an nginx property for an app + nginx:show-conf , Display app nginx config + nginx:validate [] [--clean], Validates and optionally cleans up invalid nginx configurations +help_content +} diff --git a/plugins/nginx-vhosts/internal-functions b/plugins/nginx-vhosts/internal-functions index 51e7673e2..a79a69ef8 100755 --- a/plugins/nginx-vhosts/internal-functions +++ b/plugins/nginx-vhosts/internal-functions @@ -204,36 +204,6 @@ nginx_vhosts_conf_clean_func() { rm -f "$NGINX_CONF" } -nginx_vhosts_help_content_func() { - declare desc="return nginx plugin help content" - cat < [-t], Show the nginx access logs for an application (-t follows) - nginx:build-config , (Re)builds nginx config for given app - nginx:error-logs [-t], Show the nginx error logs for an application (-t follows) - nginx:report [] [], Displays an nginx report for one or more apps - nginx:set (), Set or clear an nginx property for an app - nginx:show-conf , Display app nginx config - nginx:validate [] [--clean], Validates and optionally cleans up invalid nginx configurations -help_content -} - -cmd-nginx-vhosts-help() { - if [[ $1 == "nginx:help" ]]; then - echo -e 'Usage: dokku nginx[:COMMAND]' - echo '' - echo 'Interact with Dokku'"'"'s Nginx proxy.' - echo '' - echo 'Additional commands:' - nginx_vhosts_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - nginx_vhosts_help_content_func - else - cat <, Disable an installed plugin (third-party only) - plugin:enable , Enable a previously disabled plugin - plugin:install [--core|git-url [--committish tag|branch|commit|--name custom-plugin-name]], Optionally download git-url (with custom tag/committish) & run install trigger for active plugins (or only core ones) - plugin:install-dependencies [--core], Run install-dependencies trigger for active plugins (or only core ones) - plugin:list, Print active plugins - plugin:trigger , Trigger an arbitrary plugin hook - plugin:uninstall , Uninstall a plugin (third-party only) - plugin:update [name [committish]], Optionally update named plugin from git (with custom tag/committish) & run update trigger for active plugins -help_content - } - - if [[ $1 == "plugin:help" ]]; then - echo -e 'Usage: dokku plugin[:COMMAND]' - echo '' - echo 'View installed plugins and manage community plugins.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + cmd-plugin-help "$@" ;; *) diff --git a/plugins/plugin/help-functions b/plugins/plugin/help-functions new file mode 100755 index 000000000..b30b86660 --- /dev/null +++ b/plugins/plugin/help-functions @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-plugin-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="plugin" + local plugin_description="Manage installed plugins" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat <, Disable an installed plugin (third-party only) + plugin:enable , Enable a previously disabled plugin + plugin:install [--core|git-url [--committish tag|branch|commit|--name custom-plugin-name]], Optionally download git-url (with custom tag/committish) & run install trigger for active plugins (or only core ones) + plugin:install-dependencies [--core], Run install-dependencies trigger for active plugins (or only core ones) + plugin:list, Print active plugins + plugin:trigger , Trigger an arbitrary plugin hook + plugin:uninstall , Uninstall a plugin (third-party only) + plugin:update [name [committish]], Optionally update named plugin from git (with custom tag/committish) & run update trigger for active plugins +help_content +} diff --git a/plugins/proxy/commands b/plugins/proxy/commands index 4ac263c8e..742fe187d 100755 --- a/plugins/proxy/commands +++ b/plugins/proxy/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash [[ " help proxy:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" -source "$PLUGIN_AVAILABLE_PATH/proxy/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/proxy/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x diff --git a/plugins/proxy/help-functions b/plugins/proxy/help-functions new file mode 100755 index 000000000..fb84aa123 --- /dev/null +++ b/plugins/proxy/help-functions @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-proxy-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="proxy" + local plugin_description="Manage the proxy integration for an app" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat <, [DEPRECATED] Show proxy settings for app + proxy:disable , Disable proxy for app + proxy:enable , Enable proxy for app + proxy:ports , List proxy port mappings for app + proxy:ports-add [::...], Add proxy port mappings to an app + proxy:ports-clear , Clear all proxy port mappings for an app + proxy:ports-remove [|::...], Remove specific proxy port mappings from an app + proxy:ports-set [::...], Set proxy port mappings for an app + proxy:report [] [], Displays a proxy report for one or more apps + proxy:set , Set proxy type for app +help_content +} diff --git a/plugins/proxy/internal-functions b/plugins/proxy/internal-functions index 4e20c046a..0f36aece3 100755 --- a/plugins/proxy/internal-functions +++ b/plugins/proxy/internal-functions @@ -75,36 +75,3 @@ fn-proxy-enabled() { fi echo "$PROXY_ENABLED" } - -proxy_help_content_func() { - declare desc="return proxy plugin help content" - cat <, [DEPRECATED] Show proxy settings for app - proxy:disable , Disable proxy for app - proxy:enable , Enable proxy for app - proxy:ports , List proxy port mappings for app - proxy:ports-add [::...], Add proxy port mappings to an app - proxy:ports-clear , Clear all proxy port mappings for an app - proxy:ports-remove [|::...], Remove specific proxy port mappings from an app - proxy:ports-set [::...], Set proxy port mappings for an app - proxy:report [] [], Displays a proxy report for one or more apps - proxy:set , Set proxy type for app -help_content -} - -cmd-proxy-help() { - if [[ $1 == "proxy:help" ]]; then - echo -e 'Usage: dokku proxy[:COMMAND]' - echo '' - echo 'Manage the proxy used by dokku on a per app.' - echo '' - echo 'Additional commands:' - proxy_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - proxy_help_content_func - else - cat <, List processes running in app container(s) - ps:inspect , Displays a sanitized version of docker inspect for an app - ps:scale = [=...], Get/Set how many instances of a given process to run - ps:start , Start app container(s) - ps:startall, Starts all apps via command line - ps:stop , Stop app container(s) - ps:stopall, Stop all app container(s) - ps:rebuild , Rebuild an app from source - ps:rebuildall, Rebuild all apps from source - ps:report [] [], Displays a process report for one or more apps - ps:restart , Restart app container(s) - ps:restartall, Restart all deployed app containers - ps:restore, Start previously running apps e.g. after reboot - ps:restart-policy , Shows the restart-policy for an app - ps:set-restart-policy , Sets app restart-policy -help_content - } - - if [[ $1 == "ps:help" ]]; then - echo -e 'Usage: dokku ps[:COMMAND]' - echo '' - echo 'List running processes in container, and restart app.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + cmd-ps-help "$@" ;; *) diff --git a/plugins/ps/help-functions b/plugins/ps/help-functions new file mode 100755 index 000000000..72ab28103 --- /dev/null +++ b/plugins/ps/help-functions @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-ps-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="ps" + local plugin_description="Manage container processes" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat <, List processes running in app container(s) + ps:inspect , Displays a sanitized version of docker inspect for an app + ps:scale = [=...], Get/Set how many instances of a given process to run + ps:start , Start app container(s) + ps:startall, Starts all apps via command line + ps:stop , Stop app container(s) + ps:stopall, Stop all app container(s) + ps:rebuild , Rebuild an app from source + ps:rebuildall, Rebuild all apps from source + ps:report [] [], Displays a process report for one or more apps + ps:restart , Restart app container(s) + ps:restartall, Restart all deployed app containers + ps:restore, Start previously running apps e.g. after reboot + ps:restart-policy , Shows the restart-policy for an app + ps:set-restart-policy , Sets app restart-policy +help_content +} diff --git a/plugins/repo/src/commands/commands.go b/plugins/repo/src/commands/commands.go index 03213873f..e7aae8f06 100644 --- a/plugins/repo/src/commands/commands.go +++ b/plugins/repo/src/commands/commands.go @@ -14,7 +14,7 @@ import ( const ( helpHeader = `Usage: dokku repo[:COMMAND] -Runs commands that interact with the app's repo +Manage the app's repo Additional commands:` @@ -40,7 +40,7 @@ func main() { if err == nil && strings.Contains(string(output), "--all") { fmt.Println(helpContent) } else { - fmt.Print("\n repo, Runs commands that interact with the app's repo\n") + fmt.Print("\n repo, Manage the app's repo\n") } default: dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT")) diff --git a/plugins/resource/src/commands/commands.go b/plugins/resource/src/commands/commands.go index a998d631d..46cbd806b 100644 --- a/plugins/resource/src/commands/commands.go +++ b/plugins/resource/src/commands/commands.go @@ -14,7 +14,7 @@ import ( const ( helpHeader = `Usage: dokku resource[:COMMAND] -Manages resource settings for an app +Manage resource settings for an app Additional commands:` @@ -43,7 +43,7 @@ func main() { if err == nil && strings.Contains(string(output), "--all") { fmt.Println(helpContent) } else { - fmt.Print("\n resource, Manages resource settings for an app\n") + fmt.Print("\n resource, Manage resource settings for an app\n") } default: dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT")) diff --git a/plugins/scheduler-docker-local/commands b/plugins/scheduler-docker-local/commands index 564163c53..7d260eb13 100755 --- a/plugins/scheduler-docker-local/commands +++ b/plugins/scheduler-docker-local/commands @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/help-functions" case "$1" in help | scheduler-docker-local:help) diff --git a/plugins/scheduler-docker-local/help-functions b/plugins/scheduler-docker-local/help-functions new file mode 100755 index 000000000..cdfa2d3ba --- /dev/null +++ b/plugins/scheduler-docker-local/help-functions @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-scheduler-docker-local-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="scheduler-docker-local" + local plugin_description="Manage the docker-local scheduler integration for an app" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat <] [], Displays a scheduler-docker-local report for one or more apps + scheduler-docker-local:set (), Set or clear a scheduler-docker-local property for an app +help_content +} diff --git a/plugins/scheduler-docker-local/internal-functions b/plugins/scheduler-docker-local/internal-functions index 955f9b5df..0e2dc161b 100755 --- a/plugins/scheduler-docker-local/internal-functions +++ b/plugins/scheduler-docker-local/internal-functions @@ -65,32 +65,6 @@ cmd-scheduler-docker-local-report-single() { fi } -scheduler_docker_local_help_content_func() { - declare desc="return scheduler-docker-local plugin help content" - cat <] [], Displays a scheduler-docker-local report for one or more apps - scheduler-docker-local:set (), Set or clear a scheduler-docker-local property for an app -help_content -} - -cmd-scheduler-docker-local-help() { - if [[ $1 == "scheduler-docker-local:help" ]]; then - echo -e 'Usage: dokku scheduler-docker-local[:COMMAND]' - echo '' - echo 'Manages the scheduler-docker-local integration for an app.' - echo '' - echo 'Additional commands:' - scheduler_docker_local_help_content_func | sort | column -c2 -t -s, - echo '' - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - scheduler_docker_local_help_content_func - else - cat < [/path/to/key], Add a new public key by pipe or path + ssh-keys:remove , Remove SSH public key by name +help_content +} diff --git a/plugins/ssh-keys/internal-functions b/plugins/ssh-keys/internal-functions index c00fec062..09793be6f 100755 --- a/plugins/ssh-keys/internal-functions +++ b/plugins/ssh-keys/internal-functions @@ -2,33 +2,6 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -ssh_keys_help_content_func() { - declare desc="return ssh-keys plugin help content" - cat < [/path/to/key], Add a new public key by pipe or path - ssh-keys:remove , Remove SSH public key by name -help_content -} - -cmd-ssh-keys-help() { - if [[ $1 == "ssh-keys:help" ]]; then - echo -e 'Usage: dokku ssh-keys[:COMMAND]' - echo '' - echo 'Manage public ssh keys that are allowed to connect to Dokku' - echo '' - echo 'Additional commands:' - ssh_keys_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - ssh_keys_help_content_func - else - cat <, List bind mounts for app's container(s) (host:container) + storage:mount , Create a new bind mount + storage:report [] [], Displays a checks report for one or more apps + storage:unmount , Remove an existing bind mount +help_content +} diff --git a/plugins/storage/internal-functions b/plugins/storage/internal-functions index 6366b8f80..efa35d4b7 100755 --- a/plugins/storage/internal-functions +++ b/plugins/storage/internal-functions @@ -75,33 +75,6 @@ fn-storage-bind-mounts() { fi } -storage_help_content_func() { - declare desc="return storage plugin help content" - cat <, List bind mounts for app's container(s) (host:container) - storage:mount , Create a new bind mount - storage:report [] [], Displays a checks report for one or more apps - storage:unmount , Remove an existing bind mount -help_content -} - -cmd-storage-help() { - if [[ $1 == "storage:help" ]]; then - echo -e 'Usage: dokku storage[:COMMAND]' - echo '' - echo 'Mount local volume / directories inside containers.' - echo '' - echo 'Additional commands:' - storage_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - storage_help_content_func - else - cat <, List all app image tags - tags:create , Add tag to latest running app image - tags:deploy , Deploy tagged app image - tags:destroy , Remove app image tag -help_content - } - - if [[ $1 == "tags:help" ]]; then - echo -e 'Usage: dokku tags[:COMMAND]' - echo '' - echo 'Manage docker image tags.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + cmd-tags-help "$@" ;; *) diff --git a/plugins/tags/help-functions b/plugins/tags/help-functions new file mode 100755 index 000000000..dbb013ecf --- /dev/null +++ b/plugins/tags/help-functions @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-tags-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="tags" + local plugin_description="Manage docker image tags" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat <, List all app image tags + tags:create , Add tag to latest running app image + tags:deploy , Deploy tagged app image + tags:destroy , Remove app image tag +help_content +} diff --git a/plugins/tar/commands b/plugins/tar/commands index a7df11a82..7ae2dcc7a 100755 --- a/plugins/tar/commands +++ b/plugins/tar/commands @@ -1,12 +1,12 @@ #!/usr/bin/env bash [[ " help tar:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" -source "$PLUGIN_AVAILABLE_PATH/tar/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/tar/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in help | tar:help) - cmd-tar-help "$1" + cmd-tar-help "$@" ;; *) diff --git a/plugins/tar/help-functions b/plugins/tar/help-functions new file mode 100755 index 000000000..7418c7a33 --- /dev/null +++ b/plugins/tar/help-functions @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-tar-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="tar" + local plugin_description="Manage app deploys via tar" + + if [[ "$CMD" == "$plugin_name:help" ]]; then + echo -e "Usage: dokku $plugin_name[:COMMAND]" + echo '' + echo "$plugin_description" + echo '' + echo 'Additional commands:' + fn-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-help-content + else + cat <, Reads an tarball containing the app from stdin + tar:from , Loads an app tarball from url +help_content +} diff --git a/plugins/tar/internal-functions b/plugins/tar/internal-functions deleted file mode 100755 index 05648d755..000000000 --- a/plugins/tar/internal-functions +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail -[[ $DOKKU_TRACE ]] && set -x - -tar_help_content_func() { - declare desc="return tar plugin help content" - cat <, Reads an tarball containing the app from stdin - tar:from , Loads an app tarball from url -help_content -} - -cmd-tar-help() { - if [[ $1 == "tar:help" ]]; then - echo -e 'Usage: dokku tar[:COMMAND]' - echo '' - echo 'An alternative to using git, apps are loaded via tarballs instead.' - echo '' - echo 'Additional commands:' - tar_help_content_func | sort | column -c2 -t -s, - elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then - tar_help_content_func - else - cat < Date: Mon, 10 Feb 2020 00:37:24 -0500 Subject: [PATCH 04/11] chore: drop missing commands --- dokku | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dokku b/dokku index 1cf34149d..51d2fced2 100755 --- a/dokku +++ b/dokku @@ -136,10 +136,7 @@ execute_dokku_cmd() { nginx | nginx:*) local PLUGIN_NAME=${PLUGIN_NAME/nginx/nginx-vhosts} ;; - deploy | delete | ls | run | cleanup) - local PLUGIN_NAME="00_dokku-standard" - ;; - url | urls | report) + deploy | run | cleanup | url | urls | report) local PLUGIN_NAME="00_dokku-standard" ;; esac From e67b96780da8ca4e1f3d749d02b6523450262d95 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 01:40:30 -0500 Subject: [PATCH 05/11] refactor: unify command declaration across codebase --- docs/development/plugin-creation.md | 8 +++---- plugins/00_dokku-standard/subcommands/report | 5 +++-- plugins/00_dokku-standard/subcommands/run | 6 +++--- plugins/00_dokku-standard/subcommands/urls | 5 ++++- plugins/20_events/subcommands/default | 7 +++++-- plugins/20_events/subcommands/list | 4 +++- plugins/20_events/subcommands/off | 4 +++- plugins/20_events/subcommands/on | 4 +++- plugins/apps/internal-functions | 8 ++++--- plugins/apps/subcommands/clone | 7 +++---- plugins/apps/subcommands/create | 7 +++++-- plugins/apps/subcommands/destroy | 13 +++++++----- plugins/apps/subcommands/exists | 2 +- plugins/apps/subcommands/lock | 3 +-- plugins/apps/subcommands/locked | 1 + plugins/apps/subcommands/rename | 11 +++++----- plugins/certs/internal-functions | 15 +++++++------ plugins/certs/subcommands/add | 12 +++++------ plugins/certs/subcommands/generate | 6 ++++-- plugins/certs/subcommands/remove | 10 +++++---- plugins/checks/internal-functions | 5 +++-- plugins/checks/subcommands/default | 8 ++++--- plugins/checks/subcommands/disable | 5 +++-- plugins/checks/subcommands/enable | 5 +++-- plugins/checks/subcommands/run | 5 +++-- plugins/checks/subcommands/skip | 5 +++-- plugins/common/functions | 3 +-- plugins/docker-options/internal-functions | 5 +++-- plugins/docker-options/subcommands/add | 10 +++++---- plugins/docker-options/subcommands/clear | 4 ++-- plugins/docker-options/subcommands/default | 10 +++++---- plugins/docker-options/subcommands/remove | 10 +++++---- plugins/domains/internal-functions | 5 +++-- plugins/domains/subcommands/add | 9 ++++---- plugins/domains/subcommands/add-global | 7 ++++--- plugins/domains/subcommands/clear | 10 +++++---- plugins/domains/subcommands/clear-global | 4 ++-- plugins/domains/subcommands/default | 5 +++-- plugins/domains/subcommands/disable | 9 +++++--- plugins/domains/subcommands/enable | 9 +++++--- plugins/domains/subcommands/remove | 9 ++++---- plugins/domains/subcommands/remove-global | 7 ++++--- plugins/domains/subcommands/set | 9 ++++---- plugins/domains/subcommands/set-global | 7 ++++--- plugins/domains/subcommands/setup | 9 +++++--- plugins/enter/subcommands/default | 21 ++++++++++--------- plugins/git/functions | 14 ++++++++----- plugins/git/internal-functions | 5 +++-- plugins/git/subcommands/initialize | 6 +++--- plugins/git/subcommands/set | 5 +++-- plugins/logs/subcommands/default | 12 ++++++----- plugins/logs/subcommands/failed | 4 ++-- plugins/nginx-vhosts/internal-functions | 5 +++-- plugins/nginx-vhosts/subcommands/access-logs | 3 ++- plugins/nginx-vhosts/subcommands/build-config | 6 ++++-- plugins/nginx-vhosts/subcommands/set | 5 +++-- plugins/nginx-vhosts/subcommands/show-conf | 6 +++--- plugins/nginx-vhosts/subcommands/validate | 8 ++++--- plugins/plugin/internal-functions | 3 ++- plugins/plugin/subcommands/disable | 8 ++++--- plugins/plugin/subcommands/enable | 8 ++++--- plugins/plugin/subcommands/install | 10 +++++---- .../plugin/subcommands/install-dependencies | 7 +++++-- plugins/plugin/subcommands/trigger | 2 +- plugins/plugin/subcommands/uninstall | 8 ++++--- plugins/plugin/subcommands/update | 9 ++++---- plugins/proxy/internal-functions | 5 +++-- plugins/proxy/subcommands/default | 8 ++++--- plugins/proxy/subcommands/disable | 8 ++++--- plugins/proxy/subcommands/enable | 8 ++++--- plugins/proxy/subcommands/ports | 7 ++++--- plugins/proxy/subcommands/ports-add | 8 ++++--- plugins/proxy/subcommands/ports-clear | 7 ++++--- plugins/proxy/subcommands/ports-remove | 8 ++++--- plugins/proxy/subcommands/ports-set | 8 ++++--- plugins/proxy/subcommands/set | 8 +++---- plugins/ps/internal-functions | 10 +++++---- plugins/ps/subcommands/default | 9 ++++---- plugins/ps/subcommands/rebuild | 6 ++++-- plugins/ps/subcommands/rebuildall | 3 ++- plugins/ps/subcommands/restart | 9 +++++--- plugins/ps/subcommands/restart-policy | 9 +++++--- plugins/ps/subcommands/restartall | 3 ++- plugins/ps/subcommands/restore | 5 +++-- plugins/ps/subcommands/retire | 4 +++- plugins/ps/subcommands/scale | 8 ++++--- plugins/ps/subcommands/set-restart-policy | 10 +++++---- plugins/ps/subcommands/start | 9 +++++--- plugins/ps/subcommands/startall | 3 ++- plugins/ps/subcommands/stop | 9 +++++--- plugins/ps/subcommands/stopall | 3 ++- .../scheduler-docker-local/internal-functions | 5 +++-- .../scheduler-docker-local/subcommands/set | 5 +++-- plugins/shell/subcommands/default | 2 +- plugins/ssh-keys/internal-functions | 4 +++- plugins/ssh-keys/subcommands/add | 3 ++- plugins/ssh-keys/subcommands/remove | 11 +++++----- plugins/storage/internal-functions | 14 ++++++++----- plugins/storage/subcommands/mount | 11 ++++++---- plugins/storage/subcommands/unmount | 11 ++++++---- plugins/tags/subcommands/create | 11 +++++----- plugins/tags/subcommands/default | 10 +++++---- plugins/tags/subcommands/deploy | 9 ++++---- plugins/tags/subcommands/destroy | 13 ++++++------ plugins/tar/functions | 18 +++++++++------- plugins/trace/subcommands/default | 11 ++++++---- plugins/trace/subcommands/off | 5 +++-- plugins/trace/subcommands/on | 5 +++-- 108 files changed, 475 insertions(+), 315 deletions(-) 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" } From 7a1537e38eb5f4a1687f806dba81309801932614 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 01:41:31 -0500 Subject: [PATCH 06/11] fix: correct tests --- plugins/ssh-keys/internal-functions | 2 +- tests/unit/30_buildpacks.bats | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/ssh-keys/internal-functions b/plugins/ssh-keys/internal-functions index 4d1c01249..0a9f01bd0 100755 --- a/plugins/ssh-keys/internal-functions +++ b/plugins/ssh-keys/internal-functions @@ -2,7 +2,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -cmd-list-ssh-keys() { +cmd-ssh-keys-list() { declare desc="List ssh key hashes" declare cmd="ssh-keys:list" [[ "$1" == "$cmd" ]] && shift 1 diff --git a/tests/unit/30_buildpacks.bats b/tests/unit/30_buildpacks.bats index ae955ac69..a57a8b7df 100644 --- a/tests/unit/30_buildpacks.bats +++ b/tests/unit/30_buildpacks.bats @@ -16,13 +16,13 @@ teardown() { run /bin/bash -c "dokku buildpacks" echo "output: $output" echo "status: $status" - assert_output_contains "Manages buildpacks settings for an app" + assert_output_contains "Manage buildpacks settings for an app" help_output="$output" run /bin/bash -c "dokku buildpacks:help" echo "output: $output" echo "status: $status" - assert_output_contains "Manages buildpacks settings for an app" + assert_output_contains "Manage buildpacks settings for an app" assert_output "$help_output" } From 4a60497d3eae7a3dc4a1bf42a1e18d53cd32a2b8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 01:56:50 -0500 Subject: [PATCH 07/11] feat: add tests for all help commands --- plugins/20_events/help-functions | 2 +- tests/unit/10_apps.bats | 14 ++++++++++++++ tests/unit/10_certs.bats | 14 ++++++++++++++ tests/unit/10_checks.bats | 14 ++++++++++++++ tests/unit/10_git.bats | 14 ++++++++++++++ tests/unit/10_ps-general.bats | 14 ++++++++++++++ tests/unit/10_repo.bats | 14 ++++++++++++++ tests/unit/10_tar.bats | 14 ++++++++++++++ tests/unit/20_config.bats | 14 ++++++++++++++ tests/unit/20_docker-options.bats | 14 ++++++++++++++ tests/unit/20_domains.bats | 14 ++++++++++++++ tests/unit/20_network.bats | 14 ++++++++++++++ tests/unit/20_nginx-vhosts_1.bats | 14 ++++++++++++++ tests/unit/20_resource.bats | 14 ++++++++++++++ tests/unit/20_storage.bats | 14 ++++++++++++++ tests/unit/30_events.bats | 14 ++++++++++++++ tests/unit/30_scheduler-docker-local.bats | 14 ++++++++++++++ tests/unit/30_ssh_keys.bats | 14 ++++++++++++++ tests/unit/40_plugin.bats | 14 ++++++++++++++ tests/unit/40_proxy.bats | 14 ++++++++++++++ tests/unit/40_tags.bats | 14 ++++++++++++++ tests/unit/40_trace.bats | 14 ++++++++++++++ 22 files changed, 295 insertions(+), 1 deletion(-) diff --git a/plugins/20_events/help-functions b/plugins/20_events/help-functions index f80c45058..610242ada 100755 --- a/plugins/20_events/help-functions +++ b/plugins/20_events/help-functions @@ -6,7 +6,7 @@ cmd-events-help() { declare desc="help command" declare CMD="$1" local plugin_name="events" - local plugin_description="Interact with Dokku event logger" + local plugin_description="Manage event logging" if [[ "$CMD" == "$plugin_name:help" ]]; then echo -e "Usage: dokku $plugin_name[:COMMAND]" diff --git a/tests/unit/10_apps.bats b/tests/unit/10_apps.bats index ccb4bbf44..0c3464224 100644 --- a/tests/unit/10_apps.bats +++ b/tests/unit/10_apps.bats @@ -10,6 +10,20 @@ teardown() { global_teardown } +@test "(apps) apps:help" { + run /bin/bash -c "dokku apps" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage apps" + help_output="$output" + + run /bin/bash -c "dokku apps:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage apps" + assert_output "$help_output" +} + @test "(apps) apps:create" { run /bin/bash -c "dokku apps:create $TEST_APP" echo "output: $output" diff --git a/tests/unit/10_certs.bats b/tests/unit/10_certs.bats index 4335ff832..bfe677dd4 100644 --- a/tests/unit/10_certs.bats +++ b/tests/unit/10_certs.bats @@ -27,6 +27,20 @@ teardown() { global_teardown } +@test "(certs) certs:help" { + run /bin/bash -c "dokku certs" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage SSL (TLS) certs" + help_output="$output" + + run /bin/bash -c "dokku certs:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage SSL (TLS) certs" + assert_output "$help_output" +} + @test "(certs) certs:add" { run /bin/bash -c "dokku certs:add $TEST_APP $BATS_TMPDIR/tls/server.crt $BATS_TMPDIR/tls/server.key" echo "output: $output" diff --git a/tests/unit/10_checks.bats b/tests/unit/10_checks.bats index 51c055e03..e8ba665fb 100644 --- a/tests/unit/10_checks.bats +++ b/tests/unit/10_checks.bats @@ -16,6 +16,20 @@ teardown() { global_teardown } +@test "(checks) checks:help" { + run /bin/bash -c "dokku checks" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage zero-downtime settings" + help_output="$output" + + run /bin/bash -c "dokku checks:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage zero-downtime settings" + assert_output "$help_output" +} + @test "(checks) checks" { run /bin/bash -c "dokku checks $TEST_APP 2>/dev/null | grep $TEST_APP | xargs" echo "output: $output" diff --git a/tests/unit/10_git.bats b/tests/unit/10_git.bats index 9a7449911..d258b4c01 100644 --- a/tests/unit/10_git.bats +++ b/tests/unit/10_git.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(git) git:help" { + run /bin/bash -c "dokku git" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via git" + help_output="$output" + + run /bin/bash -c "dokku git:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via git" + assert_output "$help_output" +} + @test "(git) deploy specific branch" { run /bin/bash -c "dokku git:set --global deploy-branch global-branch" echo "output: $output" diff --git a/tests/unit/10_ps-general.bats b/tests/unit/10_ps-general.bats index 86d3a08c7..4b2fc7220 100644 --- a/tests/unit/10_ps-general.bats +++ b/tests/unit/10_ps-general.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(ps) ps:help" { + run /bin/bash -c "dokku ps" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage container processes" + help_output="$output" + + run /bin/bash -c "dokku ps:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage container processes" + assert_output "$help_output" +} + @test "(ps) ps:inspect" { dokku config:set "$TEST_APP" key=value key=value=value deploy_app dockerfile diff --git a/tests/unit/10_repo.bats b/tests/unit/10_repo.bats index 79e2805e9..9df856052 100644 --- a/tests/unit/10_repo.bats +++ b/tests/unit/10_repo.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(repo) repo:help" { + run /bin/bash -c "dokku repo" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the app's repo" + help_output="$output" + + run /bin/bash -c "dokku repo:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the app's repo" + assert_output "$help_output" +} + @test "(repo) repo:gc, repo:purge-cache" { run /bin/bash -c "dokku repo:gc $TEST_APP" echo "output: $output" diff --git a/tests/unit/10_tar.bats b/tests/unit/10_tar.bats index 3fe8204ca..7d0e3247c 100644 --- a/tests/unit/10_tar.bats +++ b/tests/unit/10_tar.bats @@ -25,6 +25,20 @@ deploy_app_tar() { sleep 5 # nginx needs some time to itself... } +@test "(tar) tar:help" { + run /bin/bash -c "dokku tar" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via tar" + help_output="$output" + + run /bin/bash -c "dokku tar:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via tar" + assert_output "$help_output" +} + @test "(tar) non-tarbomb deploy using tar:in" { deploy_app_tar nodejs-express --transform 's,^,prefix/,' diff --git a/tests/unit/20_config.bats b/tests/unit/20_config.bats index 896729748..0ca7f73ba 100644 --- a/tests/unit/20_config.bats +++ b/tests/unit/20_config.bats @@ -18,6 +18,20 @@ teardown() { global_teardown } +@test "(config) config:help" { + run /bin/bash -c "dokku config" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage global and app-specific config vars" + help_output="$output" + + run /bin/bash -c "dokku config:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage global and app-specific config vars" + assert_output "$help_output" +} + @test "(config) config:set --global" { run ssh dokku@dokku.me config:set --global test_var=true test_var2=\"hello world\" test_var3='double\"quotes' echo "output: $output" diff --git a/tests/unit/20_docker-options.bats b/tests/unit/20_docker-options.bats index 76bc8c1d3..5744a647d 100644 --- a/tests/unit/20_docker-options.bats +++ b/tests/unit/20_docker-options.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(docker-options) docker-options:help" { + run /bin/bash -c "dokku docker-options" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker options for an app" + help_output="$output" + + run /bin/bash -c "dokku docker-options:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker options for an app" + assert_output "$help_output" +} + @test "(docker-options) docker-options:add (all phases)" { run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\"" echo "output: $output" diff --git a/tests/unit/20_domains.bats b/tests/unit/20_domains.bats index 1fee4f290..b0ff43e91 100644 --- a/tests/unit/20_domains.bats +++ b/tests/unit/20_domains.bats @@ -16,6 +16,20 @@ teardown() { global_teardown } +@test "(domains) domains:help" { + run /bin/bash -c "dokku domains" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage domains used by the proxy" + help_output="$output" + + run /bin/bash -c "dokku domains:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage domains used by the proxy" + assert_output "$help_output" +} + @test "(domains) domains" { dokku domains:setup $TEST_APP run /bin/bash -c "dokku domains $TEST_APP 2>/dev/null | grep ${TEST_APP}.dokku.me" diff --git a/tests/unit/20_network.bats b/tests/unit/20_network.bats index eb7278e56..13438ffaf 100644 --- a/tests/unit/20_network.bats +++ b/tests/unit/20_network.bats @@ -43,6 +43,20 @@ assert_external_port() { fi } +@test "(network) network:help" { + run /bin/bash -c "dokku network" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage network settings for an app" + help_output="$output" + + run /bin/bash -c "dokku network:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage network settings for an app" + assert_output "$help_output" +} + @test "(network) network:set bind-all-interfaces" { deploy_app assert_nonssl_domain "${TEST_APP}.dokku.me" diff --git a/tests/unit/20_nginx-vhosts_1.bats b/tests/unit/20_nginx-vhosts_1.bats index c63ab2764..216981c6e 100644 --- a/tests/unit/20_nginx-vhosts_1.bats +++ b/tests/unit/20_nginx-vhosts_1.bats @@ -17,6 +17,20 @@ teardown() { global_teardown } +@test "(nginx) nginx:help" { + run /bin/bash -c "dokku nginx" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the nginx proxy" + help_output="$output" + + run /bin/bash -c "dokku nginx:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the nginx proxy" + assert_output "$help_output" +} + @test "(nginx-vhosts) nginx:build-config (domains:disable/enable)" { deploy_app dokku domains:disable $TEST_APP diff --git a/tests/unit/20_resource.bats b/tests/unit/20_resource.bats index 31b2f53e5..4c2a13c4f 100644 --- a/tests/unit/20_resource.bats +++ b/tests/unit/20_resource.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(resource) resource:help" { + run /bin/bash -c "dokku resource" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage resource settings for an app" + help_output="$output" + + run /bin/bash -c "dokku resource:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage resource settings for an app" + assert_output "$help_output" +} + @test "(resource) resource:limit" { run /bin/bash -c "dokku resource:limit $TEST_APP" echo "output: $output" diff --git a/tests/unit/20_storage.bats b/tests/unit/20_storage.bats index 73890cab4..05244838a 100644 --- a/tests/unit/20_storage.bats +++ b/tests/unit/20_storage.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(storage) storage:help" { + run /bin/bash -c "dokku storage" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage mounted volumes" + help_output="$output" + + run /bin/bash -c "dokku storage:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage mounted volumes" + assert_output "$help_output" +} + @test "(storage) storage:mount, storage:list, storage:umount" { run /bin/bash -c "dokku storage:mount $TEST_APP /tmp/mount:/mount" echo "output: $output" diff --git a/tests/unit/30_events.bats b/tests/unit/30_events.bats index 520e1fefe..e12098ee2 100644 --- a/tests/unit/30_events.bats +++ b/tests/unit/30_events.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(events) events:help" { + run /bin/bash -c "dokku events" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage event logging" + help_output="$output" + + run /bin/bash -c "dokku events:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage event logging" + assert_output "$help_output" +} + @test "(events) check conffiles" { run /bin/bash -c "test -f /etc/logrotate.d/dokku" echo "output: $output" diff --git a/tests/unit/30_scheduler-docker-local.bats b/tests/unit/30_scheduler-docker-local.bats index 1a2b39336..a922b0428 100644 --- a/tests/unit/30_scheduler-docker-local.bats +++ b/tests/unit/30_scheduler-docker-local.bats @@ -10,6 +10,20 @@ teardown() { global_teardown } +@test "(scheduler-docker-local) scheduler-docker-local:help" { + run /bin/bash -c "dokku scheduler-docker-local" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the docker-local scheduler integration for an app" + help_output="$output" + + run /bin/bash -c "dokku scheduler-docker-local:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the docker-local scheduler integration for an app" + assert_output "$help_output" +} + @test "(scheduler-docker-local) timer installed" { run /bin/bash -c "systemctl list-timers | grep dokku-retire" echo "output: $output" diff --git a/tests/unit/30_ssh_keys.bats b/tests/unit/30_ssh_keys.bats index b14d9a06a..b714c7a27 100644 --- a/tests/unit/30_ssh_keys.bats +++ b/tests/unit/30_ssh_keys.bats @@ -36,6 +36,20 @@ teardown() { global_teardown } +@test "(ssh-keys) ssh-keys:help" { + run /bin/bash -c "dokku ssh-keys" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage public ssh keys used for deployment" + help_output="$output" + + run /bin/bash -c "dokku ssh-keys:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage public ssh keys used for deployment" + assert_output "$help_output" +} + @test "(ssh-keys) ssh-keys:add, ssh-keys:list, ssh-keys:remove" { run /bin/bash -c "dokku ssh-keys:add name1 /tmp/testkey.pub" echo "output: $output" diff --git a/tests/unit/40_plugin.bats b/tests/unit/40_plugin.bats index a2f94b51a..3dc8ffc3e 100644 --- a/tests/unit/40_plugin.bats +++ b/tests/unit/40_plugin.bats @@ -24,6 +24,20 @@ teardown() { global_teardown } +@test "(plugin) plugin:help" { + run /bin/bash -c "dokku plugin" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage installed plugins" + help_output="$output" + + run /bin/bash -c "dokku plugin:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage installed plugins" + assert_output "$help_output" +} + @test "(plugin) plugin:install, plugin:disable, plugin:update plugin:uninstall" { run /bin/bash -c "dokku plugin:install $TEST_PLUGIN_GIT_REPO --name $TEST_PLUGIN_NAME" echo "output: $output" diff --git a/tests/unit/40_proxy.bats b/tests/unit/40_proxy.bats index 3b53ee724..ec4ee319d 100644 --- a/tests/unit/40_proxy.bats +++ b/tests/unit/40_proxy.bats @@ -41,6 +41,20 @@ assert_external_port() { fi } +@test "(proxy) proxy:help" { + run /bin/bash -c "dokku proxy" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the proxy integration for an app" + help_output="$output" + + run /bin/bash -c "dokku proxy:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the proxy integration for an app" + assert_output "$help_output" +} + @test "(proxy) proxy:enable/disable" { deploy_app assert_nonssl_domain "${TEST_APP}.dokku.me" diff --git a/tests/unit/40_tags.bats b/tests/unit/40_tags.bats index c5c5c89ea..cfa9a569d 100644 --- a/tests/unit/40_tags.bats +++ b/tests/unit/40_tags.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(tags) tags:help" { + run /bin/bash -c "dokku tags" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker image tags" + help_output="$output" + + run /bin/bash -c "dokku tags:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker image tags" + assert_output "$help_output" +} + @test "(tags) tags:create, tags, tags:destroy" { run /bin/bash -c "dokku tags:create $TEST_APP v0.9.0" echo "output: $output" diff --git a/tests/unit/40_trace.bats b/tests/unit/40_trace.bats index 5a16b139a..41bed414d 100644 --- a/tests/unit/40_trace.bats +++ b/tests/unit/40_trace.bats @@ -24,6 +24,20 @@ teardown() { assert_success } +@test "(trace) trace:help" { + run /bin/bash -c "dokku trace" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage trace mode" + help_output="$output" + + run /bin/bash -c "dokku trace:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage trace mode" + assert_output "$help_output" +} + @test "(trace) trace on" { run /bin/bash -c "dokku trace on" echo "output: $output" From 7357579af26763a37223e284a0637dfbb95511c8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 02:40:59 -0500 Subject: [PATCH 08/11] refactor: standardize trigger code --- plugins/20_events/install | 92 +++++---- plugins/app-json/post-deploy | 9 +- plugins/app-json/pre-deploy | 9 +- plugins/apps/post-delete | 11 +- plugins/builder-dockerfile/builder-build | 6 +- plugins/builder-dockerfile/builder-release | 6 +- plugins/builder-herokuish/builder-build | 6 +- plugins/builder-herokuish/builder-release | 6 +- plugins/builder-herokuish/docker-args-build | 12 +- plugins/builder-herokuish/pre-build-buildpack | 6 +- plugins/certs/post-app-clone-setup | 5 +- plugins/checks/install | 11 +- plugins/config/docker-args-deploy | 5 +- plugins/docker-options/docker-args-deploy | 9 +- plugins/domains/install | 17 +- plugins/domains/post-app-clone-setup | 5 +- plugins/git/deploy-source | 6 +- plugins/git/git-revision | 1 + plugins/git/install | 4 +- plugins/git/post-delete | 2 + plugins/nginx-vhosts/core-post-deploy | 14 +- plugins/nginx-vhosts/dependencies | 6 +- plugins/nginx-vhosts/install | 185 +++++++++--------- plugins/nginx-vhosts/post-app-clone-setup | 5 +- plugins/nginx-vhosts/post-certs-update | 9 +- plugins/nginx-vhosts/post-delete | 9 +- plugins/nginx-vhosts/post-domains-update | 7 +- plugins/nginx-vhosts/post-proxy-ports-update | 9 +- plugins/nginx-vhosts/pre-disable-vhost | 9 +- plugins/nginx-vhosts/pre-enable-vhost | 9 +- plugins/nginx-vhosts/proxy-build-config | 8 +- plugins/nginx-vhosts/proxy-clear-config | 8 +- plugins/nginx-vhosts/proxy-disable | 10 +- plugins/nginx-vhosts/proxy-enable | 10 +- plugins/proxy/post-certs-remove | 4 +- plugins/ps/app-restart | 8 +- plugins/ps/core-post-deploy | 8 +- plugins/ps/install | 1 + plugins/ps/post-create | 6 +- plugins/ps/post-stop | 8 +- plugins/ps/pre-deploy | 9 +- plugins/scheduler-docker-local/check-deploy | 12 +- .../scheduler-docker-local/core-post-deploy | 6 +- plugins/scheduler-docker-local/install | 6 +- .../post-app-clone-setup | 5 +- plugins/scheduler-docker-local/post-create | 6 +- plugins/scheduler-docker-local/post-delete | 6 +- plugins/scheduler-docker-local/pre-deploy | 6 +- plugins/scheduler-docker-local/pre-restore | 6 +- .../scheduler-app-status | 6 +- .../scheduler-docker-local/scheduler-deploy | 6 +- .../scheduler-docker-cleanup | 6 +- .../scheduler-docker-local/scheduler-inspect | 6 +- .../scheduler-is-deployed | 5 +- plugins/scheduler-docker-local/scheduler-logs | 6 +- .../scheduler-logs-failed | 6 +- .../scheduler-docker-local/scheduler-retire | 6 +- plugins/scheduler-docker-local/scheduler-run | 6 +- plugins/scheduler-docker-local/scheduler-stop | 6 +- .../scheduler-tags-create | 6 +- .../scheduler-tags-destroy | 6 +- plugins/storage/install | 11 +- plugins/tar/deploy-source | 6 +- 63 files changed, 382 insertions(+), 329 deletions(-) diff --git a/plugins/20_events/install b/plugins/20_events/install index d4b7131e3..22fefc8df 100755 --- a/plugins/20_events/install +++ b/plugins/20_events/install @@ -3,55 +3,58 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -DOKKU_RSYSLOG_FILTER_DIR=/etc/rsyslog.d -DOKKU_RSYSLOG_FILTER=$DOKKU_RSYSLOG_FILTER_DIR/99-dokku.conf -DOKKU_LOGROTATE_FILE=/etc/logrotate.d/dokku +trigger-events-install() { + declare desc="20_events install plugin trigger" + declare trigger="install" + DOKKU_RSYSLOG_FILTER_DIR=/etc/rsyslog.d + DOKKU_RSYSLOG_FILTER=$DOKKU_RSYSLOG_FILTER_DIR/99-dokku.conf + DOKKU_LOGROTATE_FILE=/etc/logrotate.d/dokku -flag_rsyslog_needs_restart=n + flag_rsyslog_needs_restart=n -# This can be done unconditionally as mkdir -p -# exits gracefully if the path already exists -# shellcheck disable=SC2174 -mkdir -m 775 -p "$DOKKU_LOGS_DIR" -case "$DOKKU_DISTRO" in - arch | debian | centos | rhel) - chgrp dokku "$DOKKU_LOGS_DIR" - ;; - *) - chown syslog:dokku "$DOKKU_LOGS_DIR" - ;; -esac - -if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then - touch "$DOKKU_EVENTS_LOGFILE" + # This can be done unconditionally as mkdir -p + # exits gracefully if the path already exists + # shellcheck disable=SC2174 + mkdir -m 775 -p "$DOKKU_LOGS_DIR" case "$DOKKU_DISTRO" in arch | debian | centos | rhel) - chgrp dokku "$DOKKU_EVENTS_LOGFILE" + chgrp dokku "$DOKKU_LOGS_DIR" ;; *) - # chown syslog:root might not work on SUSE - chown syslog:dokku "$DOKKU_EVENTS_LOGFILE" + chown syslog:dokku "$DOKKU_LOGS_DIR" ;; esac - chmod 664 "$DOKKU_EVENTS_LOGFILE" -fi -if [[ -d "$DOKKU_RSYSLOG_FILTER_DIR" && ! -f "$DOKKU_RSYSLOG_FILTER" ]]; then - cat >"$DOKKU_RSYSLOG_FILTER" <"$DOKKU_RSYSLOG_FILTER" <"$DOKKU_RSYSLOG_FILTER" <"$DOKKU_RSYSLOG_FILTER" <"$DOKKU_LOGROTATE_FILE" <"$DOKKU_LOGROTATE_FILE" </dev/null # then remove the folder and/or the symlink @@ -19,4 +20,4 @@ app_post_delete() { "$DOCKER_BIN" image rm $("$DOCKER_BIN" image list --quiet "$IMAGE_REPO" | xargs) &>/dev/null || true } -app_post_delete "$@" +trigger-apps-post-delete "$@" diff --git a/plugins/builder-dockerfile/builder-build b/plugins/builder-dockerfile/builder-build index c2ca9bfe6..2a1cf3f53 100755 --- a/plugins/builder-dockerfile/builder-build +++ b/plugins/builder-dockerfile/builder-build @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/config/functions" -trigger-builder-build-builder-dockerfile() { +trigger-builder-dockerfile-builder-build() { declare desc="builder-dockerfile builder-build plugin trigger" - declare trigger="trigger-builder-build-builder-dockerfile" + declare trigger="builder-build" declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3" if [[ "$BUILDER_TYPE" != "dockerfile" ]]; then @@ -42,4 +42,4 @@ trigger-builder-build-builder-dockerfile() { plugn trigger post-build-dockerfile "$APP" } -trigger-builder-build-builder-dockerfile "$@" +trigger-builder-dockerfile-builder-build "$@" diff --git a/plugins/builder-dockerfile/builder-release b/plugins/builder-dockerfile/builder-release index 0fec86494..7b8cef709 100755 --- a/plugins/builder-dockerfile/builder-release +++ b/plugins/builder-dockerfile/builder-release @@ -2,9 +2,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -trigger-builder-release-builder-dockerfile() { +trigger-builder-dockerfile-builder-release() { declare desc="builder-dockerfile builder-release plugin trigger" - declare trigger="trigger-builder-release-builder-dockerfile" + declare trigger="builder-release" declare BUILDER_TYPE="$1" APP="$2" IMAGE_TAG="$3" if [[ "$BUILDER_TYPE" != "dockerfile" ]]; then @@ -16,4 +16,4 @@ trigger-builder-release-builder-dockerfile() { plugn trigger post-release-dockerfile "$APP" "$IMAGE_TAG" } -trigger-builder-release-builder-dockerfile "$@" +trigger-builder-dockerfile-builder-release "$@" diff --git a/plugins/builder-herokuish/builder-build b/plugins/builder-herokuish/builder-build index 2627d74c5..44992119d 100755 --- a/plugins/builder-herokuish/builder-build +++ b/plugins/builder-herokuish/builder-build @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/config/functions" -trigger-builder-build-builder-herokuish() { +trigger-builder-herokuish-builder-build() { declare desc="builder-herokuish builder-build plugin trigger" - declare trigger="trigger-builder-build-builder-herokuish" + declare trigger="builder-build" declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3" if [[ "$BUILDER_TYPE" != "herokuish" ]]; then @@ -62,4 +62,4 @@ trigger-builder-build-builder-herokuish() { plugn trigger post-build-buildpack "$APP" "$SOURCECODE_WORK_DIR" } -trigger-builder-build-builder-herokuish "$@" +trigger-builder-herokuish-builder-build "$@" diff --git a/plugins/builder-herokuish/builder-release b/plugins/builder-herokuish/builder-release index 952e6de92..762b5f619 100755 --- a/plugins/builder-herokuish/builder-release +++ b/plugins/builder-herokuish/builder-release @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/config/functions" -trigger-builder-release-builder-herokuish() { +trigger-builder-herokuish-builder-release() { declare desc="builder-herokuish builder-release plugin trigger" - declare trigger="trigger-builder-release-builder-herokuish" + declare trigger="builder-release" declare BUILDER_TYPE="$1" APP="$2" IMAGE_TAG="$3" if [[ "$BUILDER_TYPE" != "herokuish" ]]; then @@ -39,4 +39,4 @@ trigger-builder-release-builder-herokuish() { plugn trigger post-release-buildpack "$APP" "$IMAGE_TAG" } -trigger-builder-release-builder-herokuish "$@" +trigger-builder-herokuish-builder-release "$@" diff --git a/plugins/builder-herokuish/docker-args-build b/plugins/builder-herokuish/docker-args-build index e207d266a..b720e1def 100755 --- a/plugins/builder-herokuish/docker-args-build +++ b/plugins/builder-herokuish/docker-args-build @@ -3,13 +3,11 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/config/functions" -trigger-docker-args-builder-herokuish() { +trigger-builder-herokuish-docker-args() { declare desc="builder-herokuish docker-args plugin trigger" - declare trigger="trigger-docker-args-builder-herokuish" - local APP="$1" - local STDIN - local DOKKU_APP_TYPE - local DOKKU_APP_USER + declare trigger="docker-args" + declare APP="$1" + local STDIN DOKKU_APP_TYPE DOKKU_APP_USER STDIN=$(cat) DOKKU_APP_TYPE=$(config_get "$APP" DOKKU_APP_TYPE || true) @@ -25,4 +23,4 @@ trigger-docker-args-builder-herokuish() { echo -n "$docker_args" } -trigger-docker-args-builder-herokuish "$@" +trigger-builder-herokuish-docker-args "$@" diff --git a/plugins/builder-herokuish/pre-build-buildpack b/plugins/builder-herokuish/pre-build-buildpack index e0f2ff6e3..e4e4f5e3c 100755 --- a/plugins/builder-herokuish/pre-build-buildpack +++ b/plugins/builder-herokuish/pre-build-buildpack @@ -4,9 +4,9 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -trigger-pre-build-buildpack-builder-herokuish() { +trigger-builder-herokuish-pre-build-buildpack() { declare desc="builder-herokuish pre-build-buildpack plugin trigger" - declare trigger="trigger-pre-build-buildpack-builder-herokuish" + declare trigger="pre-build-buildpack" declare APP="$1" local IMAGE CID @@ -40,4 +40,4 @@ trigger-pre-build-buildpack-builder-herokuish() { "$DOCKER_BIN" container commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" "$CID" "$IMAGE" >/dev/null } -trigger-pre-build-buildpack-builder-herokuish "$@" +trigger-builder-herokuish-pre-build-buildpack "$@" diff --git a/plugins/certs/post-app-clone-setup b/plugins/certs/post-app-clone-setup index dcfe877ea..a0b5918a5 100755 --- a/plugins/certs/post-app-clone-setup +++ b/plugins/certs/post-app-clone-setup @@ -2,8 +2,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -certs_post_app_clone_setup() { +trigger-certs-post-app-clone-setup() { declare desc="removes cert file when setting up a clone" + declare trigger="post-app-clone-setup" declare OLD_APP="$1" NEW_APP="$2" local APP_DIR="$DOKKU_ROOT/$NEW_APP" @@ -11,4 +12,4 @@ certs_post_app_clone_setup() { plugn trigger post-certs-remove "$NEW_APP" } -certs_post_app_clone_setup "$@" +trigger-certs-post-app-clone-setup "$@" diff --git a/plugins/checks/install b/plugins/checks/install index 48ec06086..b3e738e1e 100755 --- a/plugins/checks/install +++ b/plugins/checks/install @@ -56,5 +56,12 @@ migrate_checks_vars_0_6_0() { done } -migrate_checks_vars_0_5_0 "$@" -migrate_checks_vars_0_6_0 "$@" +trigger-checks-install() { + declare desc="installs the checks plugin" + declare trigger="install" + + migrate_checks_vars_0_5_0 "$@" + migrate_checks_vars_0_6_0 "$@" +} + +trigger-checks-install "$@" diff --git a/plugins/config/docker-args-deploy b/plugins/config/docker-args-deploy index 4334e5839..b4a0c0d6e 100755 --- a/plugins/config/docker-args-deploy +++ b/plugins/config/docker-args-deploy @@ -4,8 +4,9 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -config_docker_args() { +trigger-config-docker-args() { declare desc="config docker-args plugin trigger" + declare trigger="docker-args" declare APP="$1" IMAGE_TAG="$2" local ENV_ARGS IMAGE STDIN trigger @@ -22,4 +23,4 @@ config_docker_args() { fi } -config_docker_args "$@" +trigger-config-docker-args "$@" diff --git a/plugins/docker-options/docker-args-deploy b/plugins/docker-options/docker-args-deploy index 29f457ec0..f49741cfc 100755 --- a/plugins/docker-options/docker-args-deploy +++ b/plugins/docker-options/docker-args-deploy @@ -2,12 +2,11 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -docker_args() { +trigger-docker-options-docker-args() { declare desc="docker args plugin trigger" - local trigger="$0" + declare trigger="$0" + declare APP="$1" IMAGE_SOURCE_TYPE="$2" local STDIN=$(cat) - local APP="$1" - local IMAGE_SOURCE_TYPE="$2" case "$0" in *docker-args-build) @@ -77,4 +76,4 @@ docker_args() { echo -n "$STDIN$output" } -docker_args "$@" +trigger-docker-options-docker-args "$@" diff --git a/plugins/domains/install b/plugins/domains/install index ff8f02b82..3a220e1a5 100755 --- a/plugins/domains/install +++ b/plugins/domains/install @@ -2,9 +2,16 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/domains/functions" -shopt -s nullglob -for app in $DOKKU_ROOT/*/CONTAINER; do - APP=$(basename "$(dirname "$app")") - domains_setup "$APP" -done +trigger-domains-install() { + declare desc="domains install trigger" + declare trigger="install" + + shopt -s nullglob + for app in $DOKKU_ROOT/*/CONTAINER; do + APP=$(basename "$(dirname "$app")") + domains_setup "$APP" + done +} + +trigger-domains-install "$@" diff --git a/plugins/domains/post-app-clone-setup b/plugins/domains/post-app-clone-setup index 8fe3e5c60..a8ff2bcc5 100755 --- a/plugins/domains/post-app-clone-setup +++ b/plugins/domains/post-app-clone-setup @@ -2,12 +2,13 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -domains_post_app_clone_setup() { +trigger-domains-post-app-clone-setup() { declare desc="removes domain files when setting up a clone" + declare trigger="post-app-clone-setup" declare OLD_APP="$1" NEW_APP="$2" local APP_DIR="$DOKKU_ROOT/$NEW_APP" rm -rf "$APP_DIR/URLS" "$APP_DIR/VHOST" } -domains_post_app_clone_setup "$@" +trigger-domains-post-app-clone-setup "$@" diff --git a/plugins/git/deploy-source b/plugins/git/deploy-source index cc243b081..c9c26e707 100755 --- a/plugins/git/deploy-source +++ b/plugins/git/deploy-source @@ -2,9 +2,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -git_deploy_source() { +trigger-git-deploy-source() { declare desc="git deploy-source plugin trigger" - declare trigger="git_deploy_source" + declare trigger="deploy-source" declare APP="$1" local STDIN STDIN=$(cat) @@ -20,4 +20,4 @@ git_deploy_source() { fi } -git_deploy_source "$@" +trigger-git-deploy-source "$@" diff --git a/plugins/git/git-revision b/plugins/git/git-revision index 7157a6868..0ed28fe7a 100755 --- a/plugins/git/git-revision +++ b/plugins/git/git-revision @@ -6,6 +6,7 @@ set -eo pipefail trigger-git-git-revision() { declare desc="fetches the current git revision value for an application" + declare trigger="git-revision" declare APP="$1" ENV_VAR_NAME="$(fn-plugin-property-get "git" "$APP" "rev-env-var")" diff --git a/plugins/git/install b/plugins/git/install index 01f38de3b..bb13e8ef7 100755 --- a/plugins/git/install +++ b/plugins/git/install @@ -7,7 +7,10 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" trigger-git-install() { declare desc="installs the git plugin" + declare trigger="install" + fn-plugin-property-setup "git" + migrate_git_vars_0_12_0 "$@" } migrate_git_vars_0_12_0() { @@ -31,4 +34,3 @@ migrate_git_vars_0_12_0() { } trigger-git-install "$@" -migrate_git_vars_0_12_0 "$@" diff --git a/plugins/git/post-delete b/plugins/git/post-delete index 735b3cf32..9caa12790 100755 --- a/plugins/git/post-delete +++ b/plugins/git/post-delete @@ -5,7 +5,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" trigger-git-post-delete() { declare desc="destroys the git properties for a given app" + declare trigger="post-delete" declare APP="$1" + fn-plugin-property-destroy "git" "$APP" } diff --git a/plugins/nginx-vhosts/core-post-deploy b/plugins/nginx-vhosts/core-post-deploy index 9dd2c3a49..ea4293174 100755 --- a/plugins/nginx-vhosts/core-post-deploy +++ b/plugins/nginx-vhosts/core-post-deploy @@ -6,12 +6,16 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_core_post_deploy() { +trigger-nginx-vhosts-core-post-deploy() { declare desc="nginx-vhosts core-post-deploy plugin trigger" - local trigger="nginx_core_post_deploy" - local APP="$1" + declare trigger="nginx_core_post_deploy" + declare APP="$1" local HAS_NETWORK_CONFIG + if [[ "$(get_app_proxy_type "$1")" != "nginx" ]]; then + return + fi + HAS_NETWORK_CONFIG="$(plugn trigger network-config-exists "$APP")" if [[ "$HAS_NETWORK_CONFIG" == "true" ]]; then if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then @@ -24,6 +28,4 @@ nginx_core_post_deploy() { fi } -if [[ "$(get_app_proxy_type "$1")" == "nginx" ]]; then - nginx_core_post_deploy "$@" -fi +trigger-nginx-vhosts-core-post-deploy "$@" diff --git a/plugins/nginx-vhosts/dependencies b/plugins/nginx-vhosts/dependencies index 2d92cc838..842aad16a 100755 --- a/plugins/nginx-vhosts/dependencies +++ b/plugins/nginx-vhosts/dependencies @@ -29,8 +29,10 @@ nginx_install() { apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes -qq -y nginx dnsutils } -nginx_dependencies() { +trigger-nginx-vhosts-dependencies() { declare desc="installs dependencies for the nginx-vhosts plugin" + declare trigger="dependencies" + case "$DOKKU_DISTRO" in debian) nginx_install @@ -71,4 +73,4 @@ nginx_dependencies() { esac } -nginx_dependencies "$@" +trigger-nginx-vhosts-dependencies "$@" diff --git a/plugins/nginx-vhosts/install b/plugins/nginx-vhosts/install index 882c8e87c..34739247d 100755 --- a/plugins/nginx-vhosts/install +++ b/plugins/nginx-vhosts/install @@ -6,58 +6,62 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions" -fn-plugin-property-setup "nginx" +trigger-nginx-vhosts-install() { + declare desc="nginx-vhosts install trigger" + declare trigger="install" -NGINX_BIN="$(fn-nginx-vhosts-nginx-location)" -NGINX_ROOT="/etc/nginx" -NGINX_LOG_ROOT="/var/log/nginx" -NGINX_INIT_NAME="nginx" -NGINX_SUDOERS_FILE="/etc/sudoers.d/dokku-nginx" -if fn-nginx-vhosts-uses-openresty; then - NGINX_ROOT="/usr/local/openresty/nginx/conf" - NGINX_LOG_ROOT="/var/log/openresty" - NGINX_INIT_NAME="openresty" - NGINX_SUDOERS_FILE="/etc/sudoers.d/dokku-openresty" -fi + fn-plugin-property-setup "nginx" -case "$DOKKU_DISTRO" in - debian) - echo "%dokku ALL=(ALL) NOPASSWD:/usr/sbin/invoke-rc.d $NGINX_INIT_NAME reload, $NGINX_BIN -t, ${NGINX_BIN} -t -c *" >"$NGINX_SUDOERS_FILE" - ;; + NGINX_BIN="$(fn-nginx-vhosts-nginx-location)" + NGINX_ROOT="/etc/nginx" + NGINX_LOG_ROOT="/var/log/nginx" + NGINX_INIT_NAME="nginx" + NGINX_SUDOERS_FILE="/etc/sudoers.d/dokku-nginx" + if fn-nginx-vhosts-uses-openresty; then + NGINX_ROOT="/usr/local/openresty/nginx/conf" + NGINX_LOG_ROOT="/var/log/openresty" + NGINX_INIT_NAME="openresty" + NGINX_SUDOERS_FILE="/etc/sudoers.d/dokku-openresty" + fi - ubuntu) - if [[ -x /usr/bin/sv ]]; then - echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/sv reload $NGINX_INIT_NAME, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" - else - echo "%dokku ALL=(ALL) NOPASSWD:/etc/init.d/$NGINX_INIT_NAME reload, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" - fi - ;; + case "$DOKKU_DISTRO" in + debian) + echo "%dokku ALL=(ALL) NOPASSWD:/usr/sbin/invoke-rc.d $NGINX_INIT_NAME reload, $NGINX_BIN -t, ${NGINX_BIN} -t -c *" >"$NGINX_SUDOERS_FILE" + ;; - opensuse) - echo "%dokku ALL=(ALL) NOPASSWD:/sbin/service $NGINX_INIT_NAME reload, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" - ;; + ubuntu) + if [[ -x /usr/bin/sv ]]; then + echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/sv reload $NGINX_INIT_NAME, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" + else + echo "%dokku ALL=(ALL) NOPASSWD:/etc/init.d/$NGINX_INIT_NAME reload, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" + fi + ;; - arch) - echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/systemctl reload $NGINX_INIT_NAME, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" - ;; + opensuse) + echo "%dokku ALL=(ALL) NOPASSWD:/sbin/service $NGINX_INIT_NAME reload, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" + ;; - centos | rhel) - echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/systemctl reload $NGINX_INIT_NAME, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" - echo "Defaults:dokku !requiretty" >>"$NGINX_SUDOERS_FILE" - ;; -esac + arch) + echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/systemctl reload $NGINX_INIT_NAME, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" + ;; -chmod 0440 "$NGINX_SUDOERS_FILE" + centos | rhel) + echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/systemctl reload $NGINX_INIT_NAME, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" + echo "Defaults:dokku !requiretty" >>"$NGINX_SUDOERS_FILE" + ;; + esac -# if dhparam.pem has not been created, create it the first time -if [[ ! -f "$NGINX_ROOT/dhparam.pem" ]]; then - openssl dhparam -out "$NGINX_ROOT/dhparam.pem" 2048 -fi + chmod 0440 "$NGINX_SUDOERS_FILE" -mkdir -p "$NGINX_ROOT/conf.d" -chown root:root "$NGINX_ROOT/dhparam.pem" -chown root:root "$NGINX_ROOT/conf.d" -cat <"$NGINX_ROOT/conf.d/dokku.conf" + # if dhparam.pem has not been created, create it the first time + if [[ ! -f "$NGINX_ROOT/dhparam.pem" ]]; then + openssl dhparam -out "$NGINX_ROOT/dhparam.pem" 2048 + fi + + mkdir -p "$NGINX_ROOT/conf.d" + chown root:root "$NGINX_ROOT/dhparam.pem" + chown root:root "$NGINX_ROOT/conf.d" + cat <"$NGINX_ROOT/conf.d/dokku.conf" include $DOKKU_ROOT/*/nginx.conf; server_tokens off; @@ -72,51 +76,54 @@ ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDS EOF -# allow users to override their server_names_hash_bucket_size -if [[ ! -f "$NGINX_ROOT/conf.d/server_names_hash_bucket_size.conf" ]]; then - echo 'server_names_hash_bucket_size 512;' >|"$NGINX_ROOT/conf.d/server_names_hash_bucket_size.conf" -fi - -# revert dokku group changes -mkdir -p "$NGINX_LOG_ROOT" -gpasswd -a dokku adm -chgrp --quiet -R adm "$NGINX_LOG_ROOT" -gpasswd -M "$(egrep ^dokku: /etc/group | awk -F ":" '{ print $4 }')" dokku -[[ -f /etc/logrotate.d/nginx ]] && sed -i -e 's/create 0640 www-data dokku/create 0640 www-data adm/g' /etc/logrotate.d/nginx - -# Create nginx error templates -mkdir -p "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors" -cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/400-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/400-error.html" -cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/404-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/404-error.html" -cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/500-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/500-error.html" - -# patch broken nginx 1.8.0 logrotate -[[ -f /etc/logrotate.d/nginx ]] && sed -i -e 's/invoke-rc.d/service/g' /etc/logrotate.d/nginx - -# @TODO: Remove this after a few versions -for app in $(dokku_apps); do - nginx_port="$(config_get "$app" DOKKU_NGINX_PORT || true)" - nginx_ssl_port="$(config_get "$app" DOKKU_NGINX_SSL_PORT || true)" - if [[ -n "$nginx_port" ]] || [[ -n "$nginx_ssl_port" ]]; then - dokku_log_info1 "Migrating DOKKU_NGINX env variables. The following variables will be migrated" - dokku_log_info2 "DOKKU_NGINX_PORT -> DOKKU_PROXY_PORT" - dokku_log_info2 "DOKKU_NGINX_SSL_PORT -> DOKKU_PROXY_SSL_PORT" + # allow users to override their server_names_hash_bucket_size + if [[ ! -f "$NGINX_ROOT/conf.d/server_names_hash_bucket_size.conf" ]]; then + echo 'server_names_hash_bucket_size 512;' >|"$NGINX_ROOT/conf.d/server_names_hash_bucket_size.conf" fi - if [[ -n "$nginx_port" ]]; then - dokku_log_info1 "Migrating DOKKU_NGINX_PORT to DOKKU_PROXY_PORT for $app" - DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$app" DOKKU_PROXY_PORT="$nginx_port" - DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" DOKKU_NGINX_PORT - fi - if [[ -n "$nginx_ssl_port" ]]; then - dokku_log_info1 "Migrating DOKKU_NGINX_SSL_PORT to DOKKU_PROXY_SSL_PORT for $app" - DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$app" DOKKU_PROXY_SSL_PORT="$nginx_ssl_port" - DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" DOKKU_NGINX_SSL_PORT - fi -done -# avoid failing runit init calls on install -# the runit binaries are not yet available during dockerfile building -# and therefore both these calls will fail -if [[ ! -x /usr/bin/sv ]]; then - fn-nginx-vhosts-nginx-init-cmd start || fn-nginx-vhosts-nginx-init-cmd reload -fi + # revert dokku group changes + mkdir -p "$NGINX_LOG_ROOT" + gpasswd -a dokku adm + chgrp --quiet -R adm "$NGINX_LOG_ROOT" + gpasswd -M "$(egrep ^dokku: /etc/group | awk -F ":" '{ print $4 }')" dokku + [[ -f /etc/logrotate.d/nginx ]] && sed -i -e 's/create 0640 www-data dokku/create 0640 www-data adm/g' /etc/logrotate.d/nginx + + # Create nginx error templates + mkdir -p "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors" + cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/400-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/400-error.html" + cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/404-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/404-error.html" + cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/500-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/500-error.html" + + # patch broken nginx 1.8.0 logrotate + [[ -f /etc/logrotate.d/nginx ]] && sed -i -e 's/invoke-rc.d/service/g' /etc/logrotate.d/nginx + + # @TODO: Remove this after a few versions + for app in $(dokku_apps); do + nginx_port="$(config_get "$app" DOKKU_NGINX_PORT || true)" + nginx_ssl_port="$(config_get "$app" DOKKU_NGINX_SSL_PORT || true)" + if [[ -n "$nginx_port" ]] || [[ -n "$nginx_ssl_port" ]]; then + dokku_log_info1 "Migrating DOKKU_NGINX env variables. The following variables will be migrated" + dokku_log_info2 "DOKKU_NGINX_PORT -> DOKKU_PROXY_PORT" + dokku_log_info2 "DOKKU_NGINX_SSL_PORT -> DOKKU_PROXY_SSL_PORT" + fi + if [[ -n "$nginx_port" ]]; then + dokku_log_info1 "Migrating DOKKU_NGINX_PORT to DOKKU_PROXY_PORT for $app" + DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$app" DOKKU_PROXY_PORT="$nginx_port" + DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" DOKKU_NGINX_PORT + fi + if [[ -n "$nginx_ssl_port" ]]; then + dokku_log_info1 "Migrating DOKKU_NGINX_SSL_PORT to DOKKU_PROXY_SSL_PORT for $app" + DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$app" DOKKU_PROXY_SSL_PORT="$nginx_ssl_port" + DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" DOKKU_NGINX_SSL_PORT + fi + done + + # avoid failing runit init calls on install + # the runit binaries are not yet available during dockerfile building + # and therefore both these calls will fail + if [[ ! -x /usr/bin/sv ]]; then + fn-nginx-vhosts-nginx-init-cmd start || fn-nginx-vhosts-nginx-init-cmd reload + fi +} + +trigger-nginx-vhosts-install "$@" diff --git a/plugins/nginx-vhosts/post-app-clone-setup b/plugins/nginx-vhosts/post-app-clone-setup index 0afdcb9b6..c35608d1f 100755 --- a/plugins/nginx-vhosts/post-app-clone-setup +++ b/plugins/nginx-vhosts/post-app-clone-setup @@ -2,12 +2,13 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -nginx_post_app_clone_setup() { +trigger-nginx-vhosts-post-app-clone-setup() { declare desc="removes nginx files when setting up a clone" + declare trigger="post-app-clone-setup" declare OLD_APP="$1" NEW_APP="$2" local APP_DIR="$DOKKU_ROOT/$NEW_APP" rm -rf "$APP_DIR/nginx.conf" } -nginx_post_app_clone_setup "$@" +trigger-nginx-vhosts-post-app-clone-setup "$@" diff --git a/plugins/nginx-vhosts/post-certs-update b/plugins/nginx-vhosts/post-certs-update index 936bc7135..308a75ed0 100755 --- a/plugins/nginx-vhosts/post-certs-update +++ b/plugins/nginx-vhosts/post-certs-update @@ -5,10 +5,11 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_post_certs_update() { +trigger-nginx-vhosts-post-certs-update() { declare desc="unset port config vars after SSL cert is added" - local trigger="nginx_post_certs_update" - local APP="$1" + declare trigger="post-certs-update" + declare APP="$1" + if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then local DOKKU_PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT) local DOKKU_PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT) @@ -31,4 +32,4 @@ nginx_post_certs_update() { fi } -nginx_post_certs_update "$@" +trigger-nginx-vhosts-post-certs-update "$@" diff --git a/plugins/nginx-vhosts/post-delete b/plugins/nginx-vhosts/post-delete index f857dc99c..6f5194c07 100755 --- a/plugins/nginx-vhosts/post-delete +++ b/plugins/nginx-vhosts/post-delete @@ -3,4 +3,11 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" -restart_nginx "$@" >/dev/null +trigger-nginx-vhosts-post-delete() { + declare desc="nginx-vhosts post-delete trigger" + declare trigger="post-delete" + + restart_nginx "$@" >/dev/null +} + +trigger-nginx-vhosts-post-delete "$@" diff --git a/plugins/nginx-vhosts/post-domains-update b/plugins/nginx-vhosts/post-domains-update index 04dc70d1a..0a1e82b2f 100755 --- a/plugins/nginx-vhosts/post-domains-update +++ b/plugins/nginx-vhosts/post-domains-update @@ -5,10 +5,11 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_post_domains_update() { +trigger-nginx-vhosts-post-domains-update() { declare desc="calls nginx build_config when domains are updated" - declare trigger="nginx_post_domains_update" + declare trigger="post-domains-update" declare APP="$1" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then @@ -16,4 +17,4 @@ nginx_post_domains_update() { fi } -nginx_post_domains_update "$@" +trigger-nginx-vhosts-post-domains-update "$@" diff --git a/plugins/nginx-vhosts/post-proxy-ports-update b/plugins/nginx-vhosts/post-proxy-ports-update index 71af92f92..e6135d8b8 100755 --- a/plugins/nginx-vhosts/post-proxy-ports-update +++ b/plugins/nginx-vhosts/post-proxy-ports-update @@ -5,13 +5,14 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_post_proxy_ports_update() { +trigger-nginx-vhosts-post-proxy-ports-update() { declare desc="calls nginx build_config when domains are updated" - local trigger="nginx_post_proxy_ports_update" - local APP="$1" ACTION="$2" + declare trigger="post-proxy-ports-update" + declare APP="$1" ACTION="$2" + if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then nginx_build_config "$APP" fi } -nginx_post_proxy_ports_update "$@" +trigger-nginx-vhosts-post-proxy-ports-update "$@" diff --git a/plugins/nginx-vhosts/pre-disable-vhost b/plugins/nginx-vhosts/pre-disable-vhost index 8c2244f23..3ddbd6444 100755 --- a/plugins/nginx-vhosts/pre-disable-vhost +++ b/plugins/nginx-vhosts/pre-disable-vhost @@ -5,13 +5,14 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_pre_disable_vhost_trigger() { +trigger-nginx-vhosts-pre-disable-vhost() { declare desc="unset port prior to vhosts being disabled" - local trigger="nginx_pre_disable_vhost_trigger" - local APP="$1" + declare trigger="pre-disable-vhost" + declare APP="$1" + if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT DOKKU_PROXY_PORT_MAP fi } -nginx_pre_disable_vhost_trigger "$@" +trigger-nginx-vhosts-pre-disable-vhost "$@" diff --git a/plugins/nginx-vhosts/pre-enable-vhost b/plugins/nginx-vhosts/pre-enable-vhost index 2cec7b511..13c7584e3 100755 --- a/plugins/nginx-vhosts/pre-enable-vhost +++ b/plugins/nginx-vhosts/pre-enable-vhost @@ -5,13 +5,14 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_pre_enable_vhost_trigger() { +trigger-nginx-vhosts-pre-enable-vhost() { declare desc="unset port prior to vhosts being enabled" - local trigger="nginx_pre_enable_vhost_trigger" - local APP="$1" + declare trigger="pre-enable-vhost" + declare APP="$1" + if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT DOKKU_PROXY_PORT_MAP fi } -nginx_pre_enable_vhost_trigger "$@" +trigger-nginx-vhosts-pre-enable-vhost "$@" diff --git a/plugins/nginx-vhosts/proxy-build-config b/plugins/nginx-vhosts/proxy-build-config index 0f2991f40..0abb97320 100755 --- a/plugins/nginx-vhosts/proxy-build-config +++ b/plugins/nginx-vhosts/proxy-build-config @@ -5,16 +5,16 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_proxy_build_config() { +trigger-nginx-vhosts-proxy-build-config() { declare desc="build nginx config to proxy app containers from command line" - declare trigger="nginx_proxy_build_config" + declare trigger="proxy-build-config" declare APP="$1" - [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then plugn trigger network-build-config "$APP" nginx_build_config "$APP" fi } -nginx_proxy_build_config "$@" +trigger-nginx-vhosts-proxy-build-config "$@" diff --git a/plugins/nginx-vhosts/proxy-clear-config b/plugins/nginx-vhosts/proxy-clear-config index 24712eb95..d9daad61a 100755 --- a/plugins/nginx-vhosts/proxy-clear-config +++ b/plugins/nginx-vhosts/proxy-clear-config @@ -5,16 +5,16 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -trigger-nginx-vhosts-clear-config() { +trigger-nginx-vhosts-proxy-clear-config() { declare desc="clear nginx config for proxy app containers from command line" - declare trigger="trigger-nginx-vhosts-clear-config" + declare trigger="proxy-clear-config" declare APP="$1" - [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then plugn trigger network-clear-config "$APP" nginx_clear_config "$APP" fi } -trigger-nginx-vhosts-clear-config "$@" +trigger-nginx-vhosts-proxy-clear-config "$@" diff --git a/plugins/nginx-vhosts/proxy-disable b/plugins/nginx-vhosts/proxy-disable index 0e4c50139..e0ce5f7f0 100755 --- a/plugins/nginx-vhosts/proxy-disable +++ b/plugins/nginx-vhosts/proxy-disable @@ -6,16 +6,16 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -nginx_proxy_disable() { +trigger-nginx-vhosts-proxy-disable() { declare desc="disable nginx proxy" - local trigger="nginx_proxy_disable" - local APP="$1" - verify_app_name "$APP" + declare trigger="proxy-disable" + declare APP="$1" + verify_app_name "$APP" if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then disable_app_vhost "$APP" --no-restart ps_restart "$APP" fi } -nginx_proxy_disable "$@" +trigger-nginx-vhosts-proxy-disable "$@" diff --git a/plugins/nginx-vhosts/proxy-enable b/plugins/nginx-vhosts/proxy-enable index ea00bd76b..65340ee05 100755 --- a/plugins/nginx-vhosts/proxy-enable +++ b/plugins/nginx-vhosts/proxy-enable @@ -6,16 +6,16 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -nginx_proxy_enable() { +trigger-nginx-vhosts-proxy-enable() { declare desc="enable nginx proxy" - local trigger="nginx_proxy_enable" - local APP="$1" - verify_app_name "$APP" + declare trigger="proxy-enable" + declare APP="$1" + verify_app_name "$APP" if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then enable_app_vhost "$APP" --no-restart ps_restart "$APP" fi } -nginx_proxy_enable "$@" +trigger-nginx-vhosts-proxy-enable "$@" diff --git a/plugins/proxy/post-certs-remove b/plugins/proxy/post-certs-remove index 426dd03c3..07d3fe9d2 100755 --- a/plugins/proxy/post-certs-remove +++ b/plugins/proxy/post-certs-remove @@ -7,8 +7,8 @@ source "$PLUGIN_AVAILABLE_PATH/proxy/functions" trigger-proxy-post-certs-remove() { declare desc="unset port config vars after SSL cert is removed" - local trigger="nginx_post_certs_remove" - local APP="$1" + declare trigger="post-certs-remove" + declare APP="$1" DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_SSL_PORT diff --git a/plugins/ps/app-restart b/plugins/ps/app-restart index 8f7692fac..064bfd845 100755 --- a/plugins/ps/app-restart +++ b/plugins/ps/app-restart @@ -4,12 +4,12 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_app_restart() { +trigger-ps-app-restart() { declare desc="ps app-restart plugin trigger" - local trigger="ps_app_restart" - local APP="$1" + declare trigger="app-restart" + declare APP="$1" ps_restart "$APP" } -ps_app_restart "$@" +trigger-ps-app-restart "$@" diff --git a/plugins/ps/core-post-deploy b/plugins/ps/core-post-deploy index 51e87263d..b789ddc20 100755 --- a/plugins/ps/core-post-deploy +++ b/plugins/ps/core-post-deploy @@ -5,13 +5,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_core_post_deploy() { +trigger-ps-core-post-deploy() { declare desc="ps core-post-deploy plugin trigger" - local trigger="ps_core_post_deploy" - local APP="$1" + declare trigger="core-post-deploy" + declare APP="$1" remove_procfile "$APP" DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_APP_RESTORE=1 } -ps_core_post_deploy "$@" +trigger-ps-core-post-deploy "$@" diff --git a/plugins/ps/install b/plugins/ps/install index dd9125f78..4d57b90be 100755 --- a/plugins/ps/install +++ b/plugins/ps/install @@ -7,6 +7,7 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions" trigger-ps-install() { declare desc="set the default restart policy for all applications if there is not one already set" + declare trigger="install" local APPS="$(dokku_apps)" local APP diff --git a/plugins/ps/post-create b/plugins/ps/post-create index bcdbaa2ad..8434d5444 100755 --- a/plugins/ps/post-create +++ b/plugins/ps/post-create @@ -5,13 +5,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_post_create() { +trigger-ps-post-create() { declare desc="ps post-create plugin trigger" - local trigger="ps_post_create" + declare trigger="post-create" local APP="$1" local passed_phases=(deploy) add_passed_docker_option passed_phases[@] "--restart=on-failure:10" } -ps_post_create "$@" +trigger-ps-post-create "$@" diff --git a/plugins/ps/post-stop b/plugins/ps/post-stop index 0dd4c91d2..4d091c180 100755 --- a/plugins/ps/post-stop +++ b/plugins/ps/post-stop @@ -5,12 +5,12 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_post_stop() { +trigger-ps-post-stop() { declare desc="ps post-stop plugin trigger" - local trigger="ps_post_stop" - local APP="$1" + declare trigger="post-stop" + declare APP="$1" DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_APP_RESTORE=0 } -ps_post_stop "$@" +trigger-ps-post-stop "$@" diff --git a/plugins/ps/pre-deploy b/plugins/ps/pre-deploy index 67cab2171..4e4e85db8 100755 --- a/plugins/ps/pre-deploy +++ b/plugins/ps/pre-deploy @@ -4,14 +4,13 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_pre_deploy() { +trigger-ps-pre-deploy() { declare desc="ps pre-deploy plugin trigger" - local trigger="ps_pre_deploy" - local APP="$1" - local IMAGE_TAG="$2" + declare trigger="pre-deploy" + declare APP="$1" IMAGE_TAG="$2" extract_procfile "$APP" "$IMAGE_TAG" generate_scale_file "$APP" "$IMAGE_TAG" } -ps_pre_deploy "$@" +trigger-ps-pre-deploy "$@" diff --git a/plugins/scheduler-docker-local/check-deploy b/plugins/scheduler-docker-local/check-deploy index be127dfbb..6e624a1d2 100755 --- a/plugins/scheduler-docker-local/check-deploy +++ b/plugins/scheduler-docker-local/check-deploy @@ -39,14 +39,10 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/checks/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -scheduler-docker-local-check-deploy() { +trigger-scheduler-docker-local-check-deploy() { declare desc="scheduler-docker-local check-deploy plugin trigger" - local trigger="scheduler-docker-local-check-deploy" - local APP="$1" - local DOKKU_APP_CONTAINER_ID="$2" - local DOKKU_APP_CONTAINER_TYPE="$3" - local DOKKU_APP_LISTEN_PORT="$4" - local DOKKU_APP_LISTEN_IP="$5" + declare trigger="check-deploy" + declare APP="$1" DOKKU_APP_CONTAINER_ID="$2" DOKKU_APP_CONTAINER_TYPE="$3" DOKKU_APP_LISTEN_PORT="$4" DOKKU_APP_LISTEN_IP="$5" local DOKKU_SCHEDULER=$(get_app_scheduler "$APP") if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -242,4 +238,4 @@ scheduler-docker-local-check-deploy() { dokku_log_verbose "All checks successful!" } -scheduler-docker-local-check-deploy "$@" +trigger-scheduler-docker-local-check-deploy "$@" diff --git a/plugins/scheduler-docker-local/core-post-deploy b/plugins/scheduler-docker-local/core-post-deploy index c2bb39db5..53f89c928 100755 --- a/plugins/scheduler-docker-local/core-post-deploy +++ b/plugins/scheduler-docker-local/core-post-deploy @@ -4,9 +4,9 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -scheduler-docker-local-core-post-deploy() { +trigger-scheduler-docker-local-core-post-deploy() { declare desc="scheduler-docker-local core-post-deploy state cleanup" - declare trigger="scheduler-docker-local core-post-deploy" + declare trigger="core-post-deploy" declare APP="$1" local APP_ROOT="$DOKKU_ROOT/$APP" @@ -62,4 +62,4 @@ scheduler-docker-local-core-post-deploy() { shopt -u nullglob } -scheduler-docker-local-core-post-deploy "$@" +trigger-scheduler-docker-local-core-post-deploy "$@" diff --git a/plugins/scheduler-docker-local/install b/plugins/scheduler-docker-local/install index 41e05975d..780159608 100755 --- a/plugins/scheduler-docker-local/install +++ b/plugins/scheduler-docker-local/install @@ -4,9 +4,9 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" -scheduler-docker-local-install() { +trigger-scheduler-docker-local-install() { declare desc="scheduler-docker-local install plugin trigger" - declare trigger="scheduler-docker-local-install" + declare trigger="install" local DOKKU_PATH mkdir -p "${DOKKU_LIB_ROOT}/data/scheduler-docker-local" @@ -58,4 +58,4 @@ EOF fi } -scheduler-docker-local-install "$@" +trigger-scheduler-docker-local-install "$@" diff --git a/plugins/scheduler-docker-local/post-app-clone-setup b/plugins/scheduler-docker-local/post-app-clone-setup index ee923ab1c..f829496a5 100755 --- a/plugins/scheduler-docker-local/post-app-clone-setup +++ b/plugins/scheduler-docker-local/post-app-clone-setup @@ -2,12 +2,13 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -scheduler-docker-local-post-app-clone-setup() { +trigger-scheduler-docker-local-post-app-clone-setup() { declare desc="removes docker-local files when setting up a clone" + declare trigger="post-app-clone-setup" declare OLD_APP="$1" NEW_APP="$2" local APP_DIR="$DOKKU_ROOT/$NEW_APP" find "$APP_DIR" -type f -name 'CONTAINER.*' -exec rm {} \; } -scheduler-docker-local-post-app-clone-setup "$@" +trigger-scheduler-docker-local-post-app-clone-setup "$@" diff --git a/plugins/scheduler-docker-local/post-create b/plugins/scheduler-docker-local/post-create index c888fd291..3315876ab 100755 --- a/plugins/scheduler-docker-local/post-create +++ b/plugins/scheduler-docker-local/post-create @@ -2,13 +2,13 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -scheduler-docker-local-post-create() { +trigger-scheduler-docker-local-post-create() { declare desc="scheduler-docker-local post-create plugin trigger" - declare trigger="scheduler-docker-local-post-create" + declare trigger="post-create" declare APP="$1" mkdir -p "${DOKKU_LIB_ROOT}/data/scheduler-docker-local/${APP}" chown -R "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "${DOKKU_LIB_ROOT}/data/scheduler-docker-local/${APP}" } -scheduler-docker-local-post-create "$@" +trigger-scheduler-docker-local-post-create "$@" diff --git a/plugins/scheduler-docker-local/post-delete b/plugins/scheduler-docker-local/post-delete index 75df108a9..af97a2817 100755 --- a/plugins/scheduler-docker-local/post-delete +++ b/plugins/scheduler-docker-local/post-delete @@ -4,9 +4,9 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -scheduler-docker-local-post-delete() { +trigger-scheduler-docker-local-post-delete() { declare desc="scheduler-docker-local post-delete plugin trigger" - declare trigger="scheduler-docker-local post-delete" + declare trigger="post-delete" declare APP="$1" local DOKKU_SCHEDULER=$(get_app_scheduler "$APP") @@ -28,4 +28,4 @@ scheduler-docker-local-post-delete() { "$DOCKER_BIN" image rm $("$DOCKER_BIN" image list --quiet "$IMAGE_REPO" | xargs) &>/dev/null || true } -scheduler-docker-local-post-delete "$@" +trigger-scheduler-docker-local-post-delete "$@" diff --git a/plugins/scheduler-docker-local/pre-deploy b/plugins/scheduler-docker-local/pre-deploy index e3b2f64dd..843fffd5b 100755 --- a/plugins/scheduler-docker-local/pre-deploy +++ b/plugins/scheduler-docker-local/pre-deploy @@ -5,9 +5,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -scheduler-docker-local-pre-deploy() { +trigger-scheduler-docker-local-pre-deploy() { declare desc="scheduler-docker-local pre-deploy plugin trigger" - declare trigger="scheduler-docker-local pre-deploy" + declare trigger="pre-deploy" declare APP="$1" IMAGE_TAG="$2" local DOKKU_SCHEDULER=$(get_app_scheduler "$APP") @@ -70,4 +70,4 @@ scheduler-docker-local-pre-deploy-precheck() { fi } -scheduler-docker-local-pre-deploy "$@" +trigger-scheduler-docker-local-pre-deploy "$@" diff --git a/plugins/scheduler-docker-local/pre-restore b/plugins/scheduler-docker-local/pre-restore index a2a427c9b..db4e8f34f 100755 --- a/plugins/scheduler-docker-local/pre-restore +++ b/plugins/scheduler-docker-local/pre-restore @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -scheduler-docker-local-pre-restore() { +trigger-scheduler-docker-local-pre-restore() { declare desc="scheduler-docker-local pre-restore plugin trigger" - declare trigger="scheduler-docker-local pre-restore" + declare trigger="pre-restore" declare DOKKU_SCHEDULER="$1" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -17,4 +17,4 @@ scheduler-docker-local-pre-restore() { "$DOCKER_BIN" container rm $("$DOCKER_BIN" container list --all --format "{{.Names}}" --filter "label=$DOKKU_CONTAINER_LABEL" --quiet | grep -E '(.+\..+\.[0-9]+\.[0-9]+$)') &>/dev/null || true } -scheduler-docker-local-pre-restore "$@" +trigger-scheduler-docker-local-pre-restore "$@" diff --git a/plugins/scheduler-docker-local/scheduler-app-status b/plugins/scheduler-docker-local/scheduler-app-status index 89eddeb50..146b6df89 100755 --- a/plugins/scheduler-docker-local/scheduler-app-status +++ b/plugins/scheduler-docker-local/scheduler-app-status @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -scheduler-app-status() { +trigger-scheduler-app-status() { declare desc="fetches the status for a given app" - declare trigger="scheduler-docker-local scheduler-app-status" + declare trigger="scheduler-app-status" declare DOKKU_SCHEDULER="$1" APP="$2" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -35,4 +35,4 @@ scheduler-app-status() { echo "$PROCS $RUNNING" } -scheduler-app-status "$@" +trigger-scheduler-app-status "$@" diff --git a/plugins/scheduler-docker-local/scheduler-deploy b/plugins/scheduler-docker-local/scheduler-deploy index 6e3b6557d..dbb439665 100755 --- a/plugins/scheduler-docker-local/scheduler-deploy +++ b/plugins/scheduler-docker-local/scheduler-deploy @@ -7,9 +7,9 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions" -scheduler-docker-local-scheduler-deploy() { +trigger-scheduler-docker-local-scheduler-deploy() { declare desc="deploys an image tag for a given application" - declare trigger="scheduler-docker-local scheduler-deploy" + declare trigger="scheduler-deploy" declare DOKKU_SCHEDULER="$1" APP="$2" IMAGE_TAG="$3" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -220,4 +220,4 @@ fn-scheduler-docker-local-extract-start-cmd() { echo "$START_CMD" } -scheduler-docker-local-scheduler-deploy "$@" +trigger-scheduler-docker-local-scheduler-deploy "$@" diff --git a/plugins/scheduler-docker-local/scheduler-docker-cleanup b/plugins/scheduler-docker-local/scheduler-docker-cleanup index 6c041d1a5..1496a0b37 100755 --- a/plugins/scheduler-docker-local/scheduler-docker-cleanup +++ b/plugins/scheduler-docker-local/scheduler-docker-cleanup @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -scheduler-docker-local-scheduler-docker-cleanup() { +trigger-scheduler-docker-local-scheduler-docker-cleanup() { declare desc="scheduler-docker-local scheduler-docker-cleanup plugin trigger" - declare trigger="scheduler-docker-local scheduler-docker-cleanup" + declare trigger="scheduler-docker-cleanup" declare DOKKU_SCHEDULER="$1" APP="$2" FORCE_CLEANUP="$3" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -42,4 +42,4 @@ scheduler-docker-local-scheduler-docker-cleanup() { fi } -scheduler-docker-local-scheduler-docker-cleanup "$@" +trigger-scheduler-docker-local-scheduler-docker-cleanup "$@" diff --git a/plugins/scheduler-docker-local/scheduler-inspect b/plugins/scheduler-docker-local/scheduler-inspect index bb79895ef..39be0638e 100755 --- a/plugins/scheduler-docker-local/scheduler-inspect +++ b/plugins/scheduler-docker-local/scheduler-inspect @@ -4,9 +4,9 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -scheduler-docker-local-scheduler-inspect() { +trigger-scheduler-docker-local-scheduler-inspect() { declare desc="scheduler-docker-local scheduler-inspect plugin trigger" - declare trigger="scheduler-docker-local scheduler-inspect" + declare trigger="scheduler-inspect" declare DOKKU_SCHEDULER="$1" APP="$2" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -60,4 +60,4 @@ EOF } -scheduler-docker-local-scheduler-inspect "$@" +trigger-scheduler-docker-local-scheduler-inspect "$@" diff --git a/plugins/scheduler-docker-local/scheduler-is-deployed b/plugins/scheduler-docker-local/scheduler-is-deployed index c86f34f98..fd71e9a41 100755 --- a/plugins/scheduler-docker-local/scheduler-is-deployed +++ b/plugins/scheduler-docker-local/scheduler-is-deployed @@ -2,8 +2,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -scheduler-docker-local-scheduler-is-deployed() { +trigger-scheduler-docker-local-scheduler-is-deployed() { declare desc="checks if an app is deployed" + declare trigger="scheduler-is-deployed" declare DOKKU_SCHEDULER="$1" APP="$2" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -20,4 +21,4 @@ scheduler-docker-local-scheduler-is-deployed() { return 1 } -scheduler-docker-local-scheduler-is-deployed "$@" +trigger-scheduler-docker-local-scheduler-is-deployed "$@" diff --git a/plugins/scheduler-docker-local/scheduler-logs b/plugins/scheduler-docker-local/scheduler-logs index d785388e8..b9c7d672b 100755 --- a/plugins/scheduler-docker-local/scheduler-logs +++ b/plugins/scheduler-docker-local/scheduler-logs @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -scheduler-docker-local-scheduler-logs() { +trigger-scheduler-docker-local-scheduler-logs() { declare desc="scheduler-docker-local scheduler-logs plugin trigger" - declare trigger="scheduler-docker-local scheduler-logs" + declare trigger="scheduler-logs" declare DOKKU_SCHEDULER="$1" APP="$2" PROCESS_TYPE="$3" TAIL="$4" PRETTY_PRINT="$5" NUM="$6" local DOKKU_LOGS_ARGS="" @@ -47,4 +47,4 @@ scheduler-docker-local-scheduler-logs() { bash -c "($DOKKU_LOGS_CMD)" } -scheduler-docker-local-scheduler-logs "$@" +trigger-scheduler-docker-local-scheduler-logs "$@" diff --git a/plugins/scheduler-docker-local/scheduler-logs-failed b/plugins/scheduler-docker-local/scheduler-logs-failed index f231b9bdc..ed0d45349 100755 --- a/plugins/scheduler-docker-local/scheduler-logs-failed +++ b/plugins/scheduler-docker-local/scheduler-logs-failed @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -scheduler-docker-local-scheduler-logs-failed() { +trigger-scheduler-docker-local-scheduler-logs-failed() { declare desc="scheduler-docker-local scheduler-logs-failed plugin trigger" - declare trigger="scheduler-docker-local scheduler-logs-failed" + declare trigger="scheduler-logs-failed" declare DOKKU_SCHEDULER="$1" APP="$2" local FAILED_CONTAINERS_FILE="${DOKKU_LIB_ROOT}/data/scheduler-docker-local/$APP/failed-containers" local DEAD_CONTAINERS=() DOKKU_LOGS_CMD=() RUNNING_CONTAINERS=() @@ -54,4 +54,4 @@ scheduler-docker-local-scheduler-logs-failed() { bash -c "($DOKKU_LOGS_CMD)" } -scheduler-docker-local-scheduler-logs-failed "$@" +trigger-scheduler-docker-local-scheduler-logs-failed "$@" diff --git a/plugins/scheduler-docker-local/scheduler-retire b/plugins/scheduler-docker-local/scheduler-retire index d60d8f8e2..d81f24fa0 100755 --- a/plugins/scheduler-docker-local/scheduler-retire +++ b/plugins/scheduler-docker-local/scheduler-retire @@ -4,9 +4,9 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions" -scheduler-docker-local-scheduler-retire() { +trigger-scheduler-docker-local-scheduler-retire() { declare desc="retires all old containers once they have aged out" - declare trigger="scheduler-docker-local scheduler-retire" + declare trigger="scheduler-retire" local DEAD_CONTAINER_FILE="${DOKKU_LIB_ROOT}/data/scheduler-docker-local/dead-containers" local APP CID CURRENT_TIME DEAD_TIME STATE @@ -52,4 +52,4 @@ scheduler-docker-local-scheduler-retire() { done } -scheduler-docker-local-scheduler-retire "$@" +trigger-scheduler-docker-local-scheduler-retire "$@" diff --git a/plugins/scheduler-docker-local/scheduler-run b/plugins/scheduler-docker-local/scheduler-run index cc3f347f7..074b90c33 100755 --- a/plugins/scheduler-docker-local/scheduler-run +++ b/plugins/scheduler-docker-local/scheduler-run @@ -5,9 +5,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -scheduler-docker-local-scheduler-run() { +trigger-scheduler-docker-local-scheduler-run() { declare desc="runs command in container based on app image" - declare trigger="scheduler-docker-local scheduler-run" + declare trigger="scheduler-run" declare DOKKU_SCHEDULER="$1" APP="$2" ENV_COUNT="$3" local CONTAINER_ID shift 3 @@ -98,4 +98,4 @@ scheduler-docker-local-scheduler-run() { return "$DOKKU_CONTAINER_EXIT_CODE" } -scheduler-docker-local-scheduler-run "$@" +trigger-scheduler-docker-local-scheduler-run "$@" diff --git a/plugins/scheduler-docker-local/scheduler-stop b/plugins/scheduler-docker-local/scheduler-stop index f5a8787ca..d1f5134c8 100755 --- a/plugins/scheduler-docker-local/scheduler-stop +++ b/plugins/scheduler-docker-local/scheduler-stop @@ -4,9 +4,9 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -scheduler-docker-local-scheduler-stop() { +trigger-scheduler-docker-local-scheduler-stop() { declare desc="scheduler-docker-local scheduler-stop plugin trigger" - declare trigger="scheduler-docker-local scheduler-stop" + declare trigger="scheduler-stop" declare DOKKU_SCHEDULER="$1" APP="$2" REMOVE_CONTAINERS="$3" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -37,4 +37,4 @@ scheduler-docker-local-scheduler-stop() { fi } -scheduler-docker-local-scheduler-stop "$@" +trigger-scheduler-docker-local-scheduler-stop "$@" diff --git a/plugins/scheduler-docker-local/scheduler-tags-create b/plugins/scheduler-docker-local/scheduler-tags-create index 128d499da..37214fe95 100755 --- a/plugins/scheduler-docker-local/scheduler-tags-create +++ b/plugins/scheduler-docker-local/scheduler-tags-create @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -scheduler-docker-local-scheduler-tags-create() { +trigger-scheduler-docker-local-scheduler-tags-create() { declare desc="scheduler-docker-local scheduler-tags-create plugin trigger" - declare trigger="scheduler-docker-local scheduler-tags-create" + declare trigger="scheduler-tags-create" declare DOKKU_SCHEDULER="$1" APP="$2" SOURCE_IMAGE="$3" TARGET_IMAGE="$4" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -34,4 +34,4 @@ is_tag_force_available() { fi } -scheduler-docker-local-scheduler-tags-create "$@" +trigger-scheduler-docker-local-scheduler-tags-create "$@" diff --git a/plugins/scheduler-docker-local/scheduler-tags-destroy b/plugins/scheduler-docker-local/scheduler-tags-destroy index 078905659..0974d3626 100755 --- a/plugins/scheduler-docker-local/scheduler-tags-destroy +++ b/plugins/scheduler-docker-local/scheduler-tags-destroy @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -scheduler-docker-local-scheduler-tags-destroy() { +trigger-scheduler-docker-local-scheduler-tags-destroy() { declare desc="scheduler-docker-local scheduler-tags-destroy plugin trigger" - declare trigger="scheduler-docker-local scheduler-tags-destroy" + declare trigger="scheduler-tags-destroy" declare DOKKU_SCHEDULER="$1" APP="$2" IMAGE_REPO="$3" IMAGE_TAG="$4" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -15,4 +15,4 @@ scheduler-docker-local-scheduler-tags-destroy() { "$DOCKER_BIN" image rm "$IMAGE_REPO:$IMAGE_TAG" } -scheduler-docker-local-scheduler-tags-destroy "$@" +trigger-scheduler-docker-local-scheduler-tags-destroy "$@" diff --git a/plugins/storage/install b/plugins/storage/install index fb23f28d0..9c9ce83bd 100755 --- a/plugins/storage/install +++ b/plugins/storage/install @@ -2,5 +2,12 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -mkdir -p "${DOKKU_LIB_ROOT}/data/storage" -chown dokku:dokku "${DOKKU_LIB_ROOT}/data/storage" +trigger-storage-install() { + declare desc="storage install trigger" + declare trigger="install" + + mkdir -p "${DOKKU_LIB_ROOT}/data/storage" + chown dokku:dokku "${DOKKU_LIB_ROOT}/data/storage" +} + +trigger-storage-install "$@" diff --git a/plugins/tar/deploy-source b/plugins/tar/deploy-source index d83e51c9e..449f9dc85 100755 --- a/plugins/tar/deploy-source +++ b/plugins/tar/deploy-source @@ -2,9 +2,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -tar_deploy_source() { +trigger-tar-deploy-source() { declare desc="tar deploy-source plugin trigger" - declare trigger="tar_deploy_source" + declare trigger="deploy-source" declare APP="$1" local STDIN STDIN=$(cat) @@ -20,4 +20,4 @@ tar_deploy_source() { fi } -tar_deploy_source "$@" +trigger-tar-deploy-source "$@" From aa6a651f1d8b2edff116e254f1aaa2ee62f0f7f0 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 02:54:31 -0500 Subject: [PATCH 09/11] tests: correct test issues --- plugins/00_dokku-standard/subcommands/urls | 2 +- plugins/docker-options/subcommands/add | 2 +- plugins/ssh-keys/internal-functions | 12 ------------ plugins/ssh-keys/subcommands/list | 11 ++++++++++- plugins/storage/subcommands/mount | 4 +++- plugins/storage/subcommands/unmount | 3 ++- tests/unit/20_config.bats | 7 ------- tests/unit/30_events.bats | 7 ------- tests/unit/40_tags.bats | 7 ------- 9 files changed, 17 insertions(+), 38 deletions(-) delete mode 100755 plugins/ssh-keys/internal-functions diff --git a/plugins/00_dokku-standard/subcommands/urls b/plugins/00_dokku-standard/subcommands/urls index 8c37b1e53..8f94cbe0d 100755 --- a/plugins/00_dokku-standard/subcommands/urls +++ b/plugins/00_dokku-standard/subcommands/urls @@ -8,7 +8,7 @@ cmd-urls() { declare cmd="url" declare APP="$2" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" get_app_urls "$@" } diff --git a/plugins/docker-options/subcommands/add b/plugins/docker-options/subcommands/add index 5d1a692a8..98233ad1a 100755 --- a/plugins/docker-options/subcommands/add +++ b/plugins/docker-options/subcommands/add @@ -10,7 +10,7 @@ cmd-docker-options-add() { [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" - verify_app_name "$2" + verify_app_name "$APP" read -ra passed_phases <<<"$(get_phases "$2")" shift 2 # everything else passed is the docker option local passed_docker_option="$*" diff --git a/plugins/ssh-keys/internal-functions b/plugins/ssh-keys/internal-functions deleted file mode 100755 index 0a9f01bd0..000000000 --- a/plugins/ssh-keys/internal-functions +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail -[[ $DOKKU_TRACE ]] && set -x - -cmd-ssh-keys-list() { - declare desc="List ssh key hashes" - declare cmd="ssh-keys:list" - [[ "$1" == "$cmd" ]] && shift 1 - - verify_ssh_key_file - sshcommand list dokku -} diff --git a/plugins/ssh-keys/subcommands/list b/plugins/ssh-keys/subcommands/list index d1d699f09..f3abd3803 100755 --- a/plugins/ssh-keys/subcommands/list +++ b/plugins/ssh-keys/subcommands/list @@ -2,6 +2,15 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/ssh-keys/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" + +cmd-ssh-keys-list() { + declare desc="List ssh key hashes" + declare cmd="ssh-keys:list" + [[ "$1" == "$cmd" ]] && shift 1 + + verify_ssh_key_file + sshcommand list dokku +} cmd-ssh-keys-list "$@" diff --git a/plugins/storage/subcommands/mount b/plugins/storage/subcommands/mount index 57db21a75..be6e91ea5 100755 --- a/plugins/storage/subcommands/mount +++ b/plugins/storage/subcommands/mount @@ -12,7 +12,9 @@ cmd-storage-mount() { declare APP="$1" MOUNT_PATH="$2" local passed_phases=(deploy run) - [[ -z "$APP" || "$MOUNT_PATH" ]] && dokku_log_fail "storage:mount requires an app and a two paths divided by colon." + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z "$MOUNT_PATH" ]] && dokku_log_fail "Please specify two paths delimited 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." diff --git a/plugins/storage/subcommands/unmount b/plugins/storage/subcommands/unmount index f5d77c06c..5fb58010b 100755 --- a/plugins/storage/subcommands/unmount +++ b/plugins/storage/subcommands/unmount @@ -12,7 +12,8 @@ cmd-storage-unmount() { declare APP="$1" MOUNT_PATH="$2" local passed_phases=(deploy run) - [[ -z "$APP" || "$MOUNT_PATH" ]] && dokku_log_fail "storage:unmount requires an app and a two paths divided by colon." + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z "$MOUNT_PATH" ]] && dokku_log_fail "Please specify two paths delimited 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." diff --git a/tests/unit/20_config.bats b/tests/unit/20_config.bats index 0ca7f73ba..0d27f0c87 100644 --- a/tests/unit/20_config.bats +++ b/tests/unit/20_config.bats @@ -19,17 +19,10 @@ teardown() { } @test "(config) config:help" { - run /bin/bash -c "dokku config" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage global and app-specific config vars" - help_output="$output" - run /bin/bash -c "dokku config:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage global and app-specific config vars" - assert_output "$help_output" } @test "(config) config:set --global" { diff --git a/tests/unit/30_events.bats b/tests/unit/30_events.bats index e12098ee2..65a3cc7e6 100644 --- a/tests/unit/30_events.bats +++ b/tests/unit/30_events.bats @@ -13,17 +13,10 @@ teardown() { } @test "(events) events:help" { - run /bin/bash -c "dokku events" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage event logging" - help_output="$output" - run /bin/bash -c "dokku events:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage event logging" - assert_output "$help_output" } @test "(events) check conffiles" { diff --git a/tests/unit/40_tags.bats b/tests/unit/40_tags.bats index cfa9a569d..4d0b41e21 100644 --- a/tests/unit/40_tags.bats +++ b/tests/unit/40_tags.bats @@ -13,17 +13,10 @@ teardown() { } @test "(tags) tags:help" { - run /bin/bash -c "dokku tags" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage docker image tags" - help_output="$output" - run /bin/bash -c "dokku tags:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage docker image tags" - assert_output "$help_output" } @test "(tags) tags:create, tags, tags:destroy" { From 1b6c0ce6b681882366af1755bc19d8403411acbf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 02:57:03 -0500 Subject: [PATCH 10/11] fix: correct help test issues --- tests/unit/10_apps.bats | 7 ------- tests/unit/10_certs.bats | 7 ------- tests/unit/10_checks.bats | 7 ------- tests/unit/10_ps-general.bats | 7 ------- tests/unit/20_docker-options.bats | 7 ------- tests/unit/20_domains.bats | 7 ------- tests/unit/40_plugin.bats | 7 ------- tests/unit/40_proxy.bats | 7 ------- tests/unit/40_trace.bats | 21 +++++++-------------- 9 files changed, 7 insertions(+), 70 deletions(-) diff --git a/tests/unit/10_apps.bats b/tests/unit/10_apps.bats index 0c3464224..e9f714fb2 100644 --- a/tests/unit/10_apps.bats +++ b/tests/unit/10_apps.bats @@ -11,17 +11,10 @@ teardown() { } @test "(apps) apps:help" { - run /bin/bash -c "dokku apps" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage apps" - help_output="$output" - run /bin/bash -c "dokku apps:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage apps" - assert_output "$help_output" } @test "(apps) apps:create" { diff --git a/tests/unit/10_certs.bats b/tests/unit/10_certs.bats index bfe677dd4..25c9b5ab2 100644 --- a/tests/unit/10_certs.bats +++ b/tests/unit/10_certs.bats @@ -28,17 +28,10 @@ teardown() { } @test "(certs) certs:help" { - run /bin/bash -c "dokku certs" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage SSL (TLS) certs" - help_output="$output" - run /bin/bash -c "dokku certs:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage SSL (TLS) certs" - assert_output "$help_output" } @test "(certs) certs:add" { diff --git a/tests/unit/10_checks.bats b/tests/unit/10_checks.bats index e8ba665fb..10811ea8e 100644 --- a/tests/unit/10_checks.bats +++ b/tests/unit/10_checks.bats @@ -17,17 +17,10 @@ teardown() { } @test "(checks) checks:help" { - run /bin/bash -c "dokku checks" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage zero-downtime settings" - help_output="$output" - run /bin/bash -c "dokku checks:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage zero-downtime settings" - assert_output "$help_output" } @test "(checks) checks" { diff --git a/tests/unit/10_ps-general.bats b/tests/unit/10_ps-general.bats index 4b2fc7220..11a935824 100644 --- a/tests/unit/10_ps-general.bats +++ b/tests/unit/10_ps-general.bats @@ -13,17 +13,10 @@ teardown() { } @test "(ps) ps:help" { - run /bin/bash -c "dokku ps" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage container processes" - help_output="$output" - run /bin/bash -c "dokku ps:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage container processes" - assert_output "$help_output" } @test "(ps) ps:inspect" { diff --git a/tests/unit/20_docker-options.bats b/tests/unit/20_docker-options.bats index 5744a647d..63d0689bc 100644 --- a/tests/unit/20_docker-options.bats +++ b/tests/unit/20_docker-options.bats @@ -13,17 +13,10 @@ teardown() { } @test "(docker-options) docker-options:help" { - run /bin/bash -c "dokku docker-options" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage docker options for an app" - help_output="$output" - run /bin/bash -c "dokku docker-options:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage docker options for an app" - assert_output "$help_output" } @test "(docker-options) docker-options:add (all phases)" { diff --git a/tests/unit/20_domains.bats b/tests/unit/20_domains.bats index b0ff43e91..91b7cd6f5 100644 --- a/tests/unit/20_domains.bats +++ b/tests/unit/20_domains.bats @@ -17,17 +17,10 @@ teardown() { } @test "(domains) domains:help" { - run /bin/bash -c "dokku domains" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage domains used by the proxy" - help_output="$output" - run /bin/bash -c "dokku domains:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage domains used by the proxy" - assert_output "$help_output" } @test "(domains) domains" { diff --git a/tests/unit/40_plugin.bats b/tests/unit/40_plugin.bats index 3dc8ffc3e..4b082931a 100644 --- a/tests/unit/40_plugin.bats +++ b/tests/unit/40_plugin.bats @@ -25,17 +25,10 @@ teardown() { } @test "(plugin) plugin:help" { - run /bin/bash -c "dokku plugin" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage installed plugins" - help_output="$output" - run /bin/bash -c "dokku plugin:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage installed plugins" - assert_output "$help_output" } @test "(plugin) plugin:install, plugin:disable, plugin:update plugin:uninstall" { diff --git a/tests/unit/40_proxy.bats b/tests/unit/40_proxy.bats index ec4ee319d..ed7bac817 100644 --- a/tests/unit/40_proxy.bats +++ b/tests/unit/40_proxy.bats @@ -42,17 +42,10 @@ assert_external_port() { } @test "(proxy) proxy:help" { - run /bin/bash -c "dokku proxy" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage the proxy integration for an app" - help_output="$output" - run /bin/bash -c "dokku proxy:help" echo "output: $output" echo "status: $status" assert_output_contains "Manage the proxy integration for an app" - assert_output "$help_output" } @test "(proxy) proxy:enable/disable" { diff --git a/tests/unit/40_trace.bats b/tests/unit/40_trace.bats index 41bed414d..23907f1c1 100644 --- a/tests/unit/40_trace.bats +++ b/tests/unit/40_trace.bats @@ -12,6 +12,13 @@ teardown() { global_teardown } +@test "(trace) trace:help" { + run /bin/bash -c "dokku trace:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage trace mode" +} + @test "(trace) trace:on" { run /bin/bash -c "dokku trace:on" echo "output: $output" @@ -24,20 +31,6 @@ teardown() { assert_success } -@test "(trace) trace:help" { - run /bin/bash -c "dokku trace" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage trace mode" - help_output="$output" - - run /bin/bash -c "dokku trace:help" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage trace mode" - assert_output "$help_output" -} - @test "(trace) trace on" { run /bin/bash -c "dokku trace on" echo "output: $output" From 35252444e12322ab962e50af8cf4135aef4f3079 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 03:43:06 -0500 Subject: [PATCH 11/11] fix: correct command name --- plugins/proxy/subcommands/ports-add | 2 +- plugins/proxy/subcommands/ports-clear | 2 +- plugins/proxy/subcommands/ports-set | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/proxy/subcommands/ports-add b/plugins/proxy/subcommands/ports-add index d829e4347..7be477df2 100755 --- a/plugins/proxy/subcommands/ports-add +++ b/plugins/proxy/subcommands/ports-add @@ -6,7 +6,7 @@ source "$PLUGIN_AVAILABLE_PATH/proxy/functions" cmd-proxy-ports-add() { declare desc="add proxy port mappings to an app" - declare cmd="proxy:add" + declare cmd="proxy:ports-add" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" diff --git a/plugins/proxy/subcommands/ports-clear b/plugins/proxy/subcommands/ports-clear index 0052e87a1..aaecac1b4 100755 --- a/plugins/proxy/subcommands/ports-clear +++ b/plugins/proxy/subcommands/ports-clear @@ -6,7 +6,7 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" cmd-proxy-ports-clear() { declare desc="clear all proxy port mappings for an app" - declare cmd="proxy:clear" + declare cmd="proxy:ports-clear" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" diff --git a/plugins/proxy/subcommands/ports-set b/plugins/proxy/subcommands/ports-set index 1844e4d02..fa116713d 100755 --- a/plugins/proxy/subcommands/ports-set +++ b/plugins/proxy/subcommands/ports-set @@ -6,7 +6,7 @@ source "$PLUGIN_AVAILABLE_PATH/proxy/functions" cmd-proxy-ports-set() { declare desc="set proxy port mappings for an app" - declare cmd="proxy:set" + declare cmd="proxy:ports-set" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1"