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 diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 162389ac1..2fbf7b77b 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -233,10 +233,10 @@ 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 + 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 $@ @@ -250,7 +250,7 @@ hello_main_cmd() { echo "Hello $APP" } -hello_main_cmd "$@" +cmd-hello-default "$@" ``` `hello/subcommands/world` @@ -261,15 +261,15 @@ 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 + declare cmd="hello:world" + [[ "$1" == "$cmd" ]] && shift 1 echo "Hello world" } -hello_world_cmd "$@" +cmd-hello-world "$@" ``` `hello/commands` 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 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/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..64ceccc8d 100755 --- a/plugins/00_dokku-standard/subcommands/report +++ b/plugins/00_dokku-standard/subcommands/report @@ -3,10 +3,11 @@ 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" + declare cmd="report" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" dokku_log_info1 "uname: $(uname -a)" dokku_log_info1 "memory: " @@ -31,4 +32,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..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" -dokku_run_cmd() { +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=() @@ -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..8f94cbe0d 100755 --- a/plugins/00_dokku-standard/subcommands/urls +++ b/plugins/00_dokku-standard/subcommands/urls @@ -3,11 +3,14 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -dokku_urls_cmd() { - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - local APP="$2" +cmd-urls() { + declare desc="reports dokku vitals for troubleshooting" + declare cmd="url" + declare APP="$2" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" get_app_urls "$@" } -dokku_urls_cmd "$@" +cmd-urls "$@" 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 <"$DOKKU_RSYSLOG_FILTER" <"$DOKKU_RSYSLOG_FILTER" <"$DOKKU_RSYSLOG_FILTER" <"$DOKKU_RSYSLOG_FILTER" <"$DOKKU_LOGROTATE_FILE" <"$DOKKU_LOGROTATE_FILE" <"$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS" } -events_on_cmd "$@" +cmd-events-on "$@" diff --git a/plugins/app-json/post-deploy b/plugins/app-json/post-deploy index f12a1ec2e..3d2eef033 100755 --- a/plugins/app-json/post-deploy +++ b/plugins/app-json/post-deploy @@ -4,14 +4,13 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/app-json/internal-functions" -app_json_post_deploy() { +trigger-app-json-post-deploy() { declare desc="app-json scripts execution" - local trigger="app_json_post_deploy" - local APP="$1" - local IMAGE_TAG="$4" + declare trigger="post-deploy" + declare APP="$1" IMAGE_TAG="$4" local PHASE_SCRIPT_KEY="postdeploy" execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY" } -app_json_post_deploy "$@" +trigger-app-json-post-deploy "$@" diff --git a/plugins/app-json/pre-deploy b/plugins/app-json/pre-deploy index f1598a7ab..b9ac30bf0 100755 --- a/plugins/app-json/pre-deploy +++ b/plugins/app-json/pre-deploy @@ -4,15 +4,14 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/app-json/internal-functions" -app_json_pre_deploy() { +trigger-app-json-pre-deploy() { declare desc="app-json scripts execution" - local trigger="app_json_pre_deploy" - local APP="$1" - local IMAGE_TAG="$2" + declare trigger="pre-deploy" + declare APP="$1" IMAGE_TAG="$2" local PHASE_SCRIPT_KEY="predeploy" execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY" execute_script "$APP" "$IMAGE_TAG" "release" } -app_json_pre_deploy "$@" +trigger-app-json-pre-deploy "$@" diff --git a/plugins/apps/commands b/plugins/apps/commands index 79b1ab4ae..d29019c87 100755 --- a/plugins/apps/commands +++ b/plugins/apps/commands @@ -1,12 +1,12 @@ #!/usr/bin/env bash [[ " help apps:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" -source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/apps/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in help | apps:help) - apps_help_cmd "$@" + cmd-apps-help "$@" ;; *) diff --git a/plugins/apps/help-functions b/plugins/apps/help-functions new file mode 100755 index 000000000..f2ed9bffa --- /dev/null +++ b/plugins/apps/help-functions @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-apps-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="apps" + local plugin_description="Manage apps" + + 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 < , 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 5f92c2439..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" @@ -78,50 +79,10 @@ 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 -} - -apps_help_cmd() { - 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 </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/apps/subcommands/clone b/plugins/apps/subcommands/clone index 8ab7ec1a3..7ba17a6a9 100755 --- a/plugins/apps/subcommands/clone +++ b/plugins/apps/subcommands/clone @@ -5,13 +5,12 @@ 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 + 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 @@ -56,4 +55,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..0a538f940 100755 --- a/plugins/apps/subcommands/create +++ b/plugins/apps/subcommands/create @@ -3,10 +3,13 @@ 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" + declare cmd="apps:create" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + apps_create "$APP" } -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..6accc0a29 100755 --- a/plugins/apps/subcommands/destroy +++ b/plugins/apps/subcommands/destroy @@ -4,14 +4,17 @@ 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" - [[ "$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" } -apps_destroy_cmd "$@" +cmd-apps-destroy "$@" diff --git a/plugins/apps/subcommands/exists b/plugins/apps/subcommands/exists index b5cbb4108..1bbc9113e 100755 --- a/plugins/apps/subcommands/exists +++ b/plugins/apps/subcommands/exists @@ -3,9 +3,9 @@ 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" + declare cmd="apps:exists" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$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..4659902c4 100755 --- a/plugins/apps/subcommands/lock +++ b/plugins/apps/subcommands/lock @@ -4,16 +4,15 @@ 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 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" } -apps_lock_cmd "$@" +cmd-apps-lock "$@" diff --git a/plugins/apps/subcommands/locked b/plugins/apps/subcommands/locked index ce27a2845..6dc51b779 100755 --- a/plugins/apps/subcommands/locked +++ b/plugins/apps/subcommands/locked @@ -4,11 +4,12 @@ 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 declare APP="$1" + verify_app_name "$APP" local LOCKED="$(apps_is_locked "$APP")" @@ -19,4 +20,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..0ce98e154 100755 --- a/plugins/apps/subcommands/rename +++ b/plugins/apps/subcommands/rename @@ -5,13 +5,14 @@ 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" - [[ -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" @@ -34,4 +35,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/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/buildpacks/src/commands/commands.go b/plugins/buildpacks/src/commands/commands.go index b4e836a12..e4a6547c9 100644 --- a/plugins/buildpacks/src/commands/commands.go +++ b/plugins/buildpacks/src/commands/commands.go @@ -14,7 +14,7 @@ import ( const ( helpHeader = `Usage: dokku buildpacks[:COMMAND] -Manages buildpacks settings for an app +Manage buildpacks settings for an app Additional commands:` @@ -44,7 +44,7 @@ func main() { if err == nil && strings.Contains(string(output), "--all") { fmt.Println(helpContent) } else { - fmt.Print("\n buildpacks, Manages buildpack settings for an app\n") + fmt.Print("\n buildpacks, Manage buildpack settings for an app\n") } default: dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT")) diff --git a/plugins/certs/commands b/plugins/certs/commands index 17fa444fc..ef21c0ee3 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -1,12 +1,12 @@ #!/usr/bin/env bash [[ " help certs:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" -source "$PLUGIN_AVAILABLE_PATH/certs/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/certs/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in help | certs:help) - certs_help_cmd "$@" + cmd-certs-help "$@" ;; *) diff --git a/plugins/certs/help-functions b/plugins/certs/help-functions new file mode 100755 index 000000000..80045e57d --- /dev/null +++ b/plugins/certs/help-functions @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-certs-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="certs" + local plugin_description="Manage SSL (TLS) certs" + + 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 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 b6ae228e0..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" @@ -71,46 +72,15 @@ 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 -} - -certs_help_cmd() { - 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/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/checks/internal-functions b/plugins/checks/internal-functions index 55ea99c69..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" @@ -65,35 +66,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 -} - -checks_help_cmd() { - 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 b29fbd6ef..f404d4a31 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -1,39 +1,12 @@ #!/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 -} - -docker_options_help_cmd() { - 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/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 72d64129c..98233ad1a 100755 --- a/plugins/docker-options/subcommands/add +++ b/plugins/docker-options/subcommands/add @@ -4,16 +4,18 @@ 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" + 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 "$APP" + 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[@]}" } -docker_options_add_cmd "$@" +cmd-docker-options-add "$@" 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 8032e9a84..ba6e59a96 100755 --- a/plugins/docker-options/subcommands/default +++ b/plugins/docker-options/subcommands/default @@ -4,13 +4,15 @@ 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" + 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 @@ -18,4 +20,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..f258a0b34 100755 --- a/plugins/docker-options/subcommands/remove +++ b/plugins/docker-options/subcommands/remove @@ -4,16 +4,18 @@ 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" + 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[@]}" } -docker_options_remove_cmd "$@" +cmd-docker-options-remove "$@" diff --git a/plugins/domains/commands b/plugins/domains/commands index 328664b40..482fbc229 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -1,12 +1,12 @@ #!/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 case "$1" in help | domains:help) - domains_help_cmd "$@" + cmd-domains-help "$@" ;; *) 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/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/internal-functions b/plugins/domains/internal-functions index 8da721b64..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" @@ -84,41 +85,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 -} - -domains_help_cmd() { - 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 < [ ...]" + 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 "$@" } -domains_add_cmd "$@" +cmd-domains-add "$@" diff --git a/plugins/domains/subcommands/add-global b/plugins/domains/subcommands/add-global index c58eed710..0a0816d32 100755 --- a/plugins/domains/subcommands/add-global +++ b/plugins/domains/subcommands/add-global @@ -4,13 +4,14 @@ 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 [ ...]" + 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 "$@" } -domains_add_global_cmd "$@" +cmd-domains-add-global "$@" diff --git a/plugins/domains/subcommands/clear b/plugins/domains/subcommands/clear index 1ea9a4b19..965f14165 100755 --- a/plugins/domains/subcommands/clear +++ b/plugins/domains/subcommands/clear @@ -4,12 +4,14 @@ 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" - 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" @@ -18,4 +20,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..ff7ae757b 100755 --- a/plugins/domains/subcommands/clear-global +++ b/plugins/domains/subcommands/clear-global @@ -4,13 +4,13 @@ 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 + declare cmd="domains:clear-global" + [[ "$1" == "$cmd" ]] && shift 1 dokku_log_info1_quiet "Clearing global domains" 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..49f3e9087 100755 --- a/plugins/domains/subcommands/default +++ b/plugins/domains/subcommands/default @@ -4,10 +4,11 @@ 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" + 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 @@ -30,4 +31,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..0757a77fe 100755 --- a/plugins/domains/subcommands/disable +++ b/plugins/domains/subcommands/disable @@ -4,11 +4,14 @@ 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" + 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" } -domains_disable_cmd "$@" +cmd-domains-disable "$@" diff --git a/plugins/domains/subcommands/enable b/plugins/domains/subcommands/enable index 8253f6a64..d4f641cb5 100755 --- a/plugins/domains/subcommands/enable +++ b/plugins/domains/subcommands/enable @@ -4,11 +4,14 @@ 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" + 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" } -domains_enable_cmd "$@" +cmd-domains-enable "$@" diff --git a/plugins/domains/subcommands/remove b/plugins/domains/subcommands/remove index 2d6127cb9..e9ee9837a 100755 --- a/plugins/domains/subcommands/remove +++ b/plugins/domains/subcommands/remove @@ -4,14 +4,15 @@ 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" - [[ -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 "$@" } -domains_remove_cmd "$@" +cmd-domains-remove "$@" diff --git a/plugins/domains/subcommands/remove-global b/plugins/domains/subcommands/remove-global index b9bba0d0f..1c2e4818d 100755 --- a/plugins/domains/subcommands/remove-global +++ b/plugins/domains/subcommands/remove-global @@ -4,13 +4,14 @@ 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 [ ...]" + 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 "$@" } -domains_remove_global_cmd "$@" +cmd-domains-remove-global "$@" diff --git a/plugins/domains/subcommands/set b/plugins/domains/subcommands/set index c61dd4c94..fdda804fa 100755 --- a/plugins/domains/subcommands/set +++ b/plugins/domains/subcommands/set @@ -4,14 +4,15 @@ 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" - [[ -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 "$@" } -domains_set_cmd "$@" +cmd-domains-set "$@" diff --git a/plugins/domains/subcommands/set-global b/plugins/domains/subcommands/set-global index 94ea71e72..9e8bd03e2 100755 --- a/plugins/domains/subcommands/set-global +++ b/plugins/domains/subcommands/set-global @@ -4,13 +4,14 @@ 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 [ ...]" + 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 "$@" } -domains_set_global_cmd "$@" +cmd-domains-set-global "$@" diff --git a/plugins/domains/subcommands/setup b/plugins/domains/subcommands/setup index b51169582..007ce1ec8 100755 --- a/plugins/domains/subcommands/setup +++ b/plugins/domains/subcommands/setup @@ -4,11 +4,14 @@ 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" + 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" } -domains_setup_cmd "$@" +cmd-domains-setup "$@" diff --git a/plugins/enter/commands b/plugins/enter/commands index de550ab23..a22c474a7 100755 --- a/plugins/enter/commands +++ b/plugins/enter/commands @@ -1,27 +1,12 @@ #!/usr/bin/env bash [[ " help enter:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/enter/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in help | enter:help) - help_content_func() { - declare desc="return enter plugin help content" - 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/enter/subcommands/default b/plugins/enter/subcommands/default index 10b7a2402..efab27c18 100755 --- a/plugins/enter/subcommands/default +++ b/plugins/enter/subcommands/default @@ -4,17 +4,18 @@ 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" - 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 @@ enter_default_cmd() { 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 @@ enter_default_cmd() { 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 @@ enter_default_cmd() { 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 @@ -63,4 +64,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..34afa72bd 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -3,18 +3,19 @@ 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) - 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/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/functions b/plugins/git/functions index db4ab4837..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" "")" @@ -123,11 +123,13 @@ 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" + 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")" @@ -195,10 +197,12 @@ 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" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + APP="$(echo "$APP" | perl -pe 's/(?/dev/null 2>&1 && apps_maybe_create "$APP" @@ -208,9 +212,9 @@ 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-*" + declare cmd="git-*" local APP="$(echo "$2" | perl -pe 's/(?, 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/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/internal-functions b/plugins/git/internal-functions index 5f87ab0fd..d7a88e8ae 100755 --- a/plugins/git/internal-functions +++ b/plugins/git/internal-functions @@ -6,9 +6,10 @@ set -eo pipefail cmd-git-report() { declare desc="displays a git report for one or more apps" - local cmd="git:report" + declare cmd="git: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" @@ -66,30 +67,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 1402f3075..a9d08e243 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -1,12 +1,12 @@ #!/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 case "$1" in help | nginx:help) - nginx_vhosts_help_cmd "$@" + cmd-nginx-vhosts-help "$@" ;; *) 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/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/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/internal-functions b/plugins/nginx-vhosts/internal-functions index fbe7a0e6f..7fe7401a1 100755 --- a/plugins/nginx-vhosts/internal-functions +++ b/plugins/nginx-vhosts/internal-functions @@ -6,9 +6,10 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" cmd-nginx-report() { declare desc="displays a nginx report for one or more apps" - local cmd="nginx:report" + declare cmd="nginx: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" @@ -204,36 +205,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 -} - -nginx_vhosts_help_cmd() { - 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 </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/nginx-vhosts/subcommands/access-logs b/plugins/nginx-vhosts/subcommands/access-logs index 890a44f72..20413d51f 100755 --- a/plugins/nginx-vhosts/subcommands/access-logs +++ b/plugins/nginx-vhosts/subcommands/access-logs @@ -4,11 +4,12 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" -nginx_logs_cmd() { +cmd-nginx-logs() { declare desc="display app nginx logs from command line" - local cmd="$1" + declare cmd="$1" + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" nginx_logs "$@" } -nginx_logs_cmd "$@" +cmd-nginx-logs "$@" diff --git a/plugins/nginx-vhosts/subcommands/build-config b/plugins/nginx-vhosts/subcommands/build-config index ca735e450..322e21d13 100755 --- a/plugins/nginx-vhosts/subcommands/build-config +++ b/plugins/nginx-vhosts/subcommands/build-config @@ -4,10 +4,12 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_build_config_cmd() { +cmd-nginx-build-config() { declare desc="build nginx config to proxy app containers from command line" - declare APP="$2" - local cmd="nginx:build-config" + declare cmd="nginx:build-config" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" local PROXY_APP_TYPE PROXY_APP_TYPE="$(get_app_proxy_type "$APP")" @@ -19,4 +21,4 @@ nginx_build_config_cmd() { fi } -nginx_build_config_cmd "$@" +cmd-nginx-build-config "$@" diff --git a/plugins/nginx-vhosts/subcommands/default b/plugins/nginx-vhosts/subcommands/default index 5851b3026..65100812e 100755 --- a/plugins/nginx-vhosts/subcommands/default +++ b/plugins/nginx-vhosts/subcommands/default @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/help-functions" -nginx_vhosts_help_cmd "nginx:help" +cmd-nginx-vhosts-help "nginx:help" diff --git a/plugins/nginx-vhosts/subcommands/set b/plugins/nginx-vhosts/subcommands/set index 6e9a688a8..475d0188a 100755 --- a/plugins/nginx-vhosts/subcommands/set +++ b/plugins/nginx-vhosts/subcommands/set @@ -4,12 +4,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -nginx-set-cmd() { +cmd-nginx-set() { declare desc="set or clear an nginx property for an app" - local cmd="nginx:set" argv=("$@") - [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare cmd="nginx:set" + [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" KEY="$2" VALUE="$3" local VALID_KEYS=("bind-address-ipv4" "bind-address-ipv6" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age") + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" [[ -z "$KEY" ]] && dokku_log_fail "No key specified" @@ -26,4 +27,4 @@ nginx-set-cmd() { fi } -nginx-set-cmd "$@" +cmd-nginx-set "$@" diff --git a/plugins/nginx-vhosts/subcommands/show-conf b/plugins/nginx-vhosts/subcommands/show-conf index 7c3630c00..355463078 100755 --- a/plugins/nginx-vhosts/subcommands/show-conf +++ b/plugins/nginx-vhosts/subcommands/show-conf @@ -3,13 +3,13 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -nginx_show_conf_cmd() { +cmd-nginx-show-conf() { declare desc="display app nginx config" - declare cmd="nginx:show-conf" argv=("$@") - [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare cmd="nginx:show-conf" + [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" - verify_app_name "$APP" + verify_app_name "$APP" if [[ ! -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then dokku_log_fail "No nginx.conf exists for $APP" fi @@ -17,4 +17,4 @@ nginx_show_conf_cmd() { cat "$DOKKU_ROOT/$APP/nginx.conf" } -nginx_show_conf_cmd "$@" +cmd-nginx-show-conf "$@" diff --git a/plugins/nginx-vhosts/subcommands/validate b/plugins/nginx-vhosts/subcommands/validate index 56f7a2319..68fbe0be1 100755 --- a/plugins/nginx-vhosts/subcommands/validate +++ b/plugins/nginx-vhosts/subcommands/validate @@ -4,11 +4,13 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" -nginx_validate_cmd() { +cmd-nginx-validate() { declare desc="validates and optionally cleans up invalid nginx configurations" - declare cmd="nginx:validate" argv=("$@") - [[ ${argv[0]} == "$cmd" ]] && shift 1 - validate_nginx "$@" + declare cmd="nginx:validate" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" FLAG="$2" + + validate_nginx "$APP" "$FLAG" } -nginx_validate_cmd "$@" +cmd-nginx-validate "$@" diff --git a/plugins/plugin/commands b/plugins/plugin/commands index 7b436b331..73902dd6e 100755 --- a/plugins/plugin/commands +++ b/plugins/plugin/commands @@ -1,34 +1,12 @@ #!/usr/bin/env bash [[ " help plugin:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/plugin/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in help | plugin:help) - help_content_func() { - declare desc="return plugin plugin help content" - 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/plugin/internal-functions b/plugins/plugin/internal-functions index df3791fbf..85a0d187c 100755 --- a/plugins/plugin/internal-functions +++ b/plugins/plugin/internal-functions @@ -3,9 +3,10 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -plugin_list_cmd() { +cmd-plugin-list() { declare desc="lists all plugins" - local cmd="plugin" + declare cmd="plugin" + [[ "$1" == "$cmd" ]] && shift 1 plugn version plugn list diff --git a/plugins/plugin/subcommands/default b/plugins/plugin/subcommands/default index 1f336719e..dd5efe334 100755 --- a/plugins/plugin/subcommands/default +++ b/plugins/plugin/subcommands/default @@ -5,4 +5,4 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions" dokku_log_warn "Deprecated: Please use plugin:list" -plugin_list_cmd "$@" +cmd-plugin-list "$@" diff --git a/plugins/plugin/subcommands/disable b/plugins/plugin/subcommands/disable index 869d22601..e420c17b7 100755 --- a/plugins/plugin/subcommands/disable +++ b/plugins/plugin/subcommands/disable @@ -5,13 +5,15 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions" -plugin_disable_cmd() { +cmd-plugin-disable() { declare desc="disables plugin via command line" - local cmd="plugin:disable" - [[ -z $2 ]] && dokku_log_fail "Please specify a plugin to disable" - local PLUGIN="$2" + declare cmd="plugin:disable" + [[ "$1" == "$cmd" ]] && shift 1 + declare PLUGIN="$1" + + [[ -z "$PLUGIN" ]] && dokku_log_fail "Please specify a plugin to disable" disable_plugin "$PLUGIN" plugin_prime_bash_completion } -plugin_disable_cmd "$@" +cmd-plugin-disable "$@" diff --git a/plugins/plugin/subcommands/enable b/plugins/plugin/subcommands/enable index fce33c21c..e16c88a14 100755 --- a/plugins/plugin/subcommands/enable +++ b/plugins/plugin/subcommands/enable @@ -5,13 +5,15 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions" -plugin_enable_cmd() { +cmd-plugin-enable() { declare desc="enables plugin via command line" - local cmd="plugin:enable" - [[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable" - local PLUGIN="$2" + declare cmd="plugin:enable" + [[ "$1" == "$cmd" ]] && shift 1 + declare PLUGIN="$1" + + [[ -z "$PLUGIN" ]] && dokku_log_fail "Please specify a plugin to enable" enable_plugin "$PLUGIN" plugin_prime_bash_completion } -plugin_enable_cmd "$@" +cmd-plugin-enable "$@" diff --git a/plugins/plugin/subcommands/install b/plugins/plugin/subcommands/install index 6516a05f2..64351ad09 100755 --- a/plugins/plugin/subcommands/install +++ b/plugins/plugin/subcommands/install @@ -5,16 +5,18 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions" -plugin_install_cmd() { +cmd-plugin-install() { declare desc="installs a plugin from URL and calls install plugin trigger via command line" - local cmd="plugin:install" - case "$2" in + declare cmd="plugin:install" + [[ "$1" == "$cmd" ]] && shift 1 + declare FLAG="$1" + + case "$FLAG" in --core) - [[ "$#" -gt 2 ]] && dokku_log_info1_quiet "Cannot install additional core plugins, running core plugin install trigger" + [[ "$#" -gt 1 ]] && dokku_log_info1_quiet "Cannot install additional core plugins, running core plugin install trigger" PLUGIN_PATH="$PLUGIN_CORE_PATH" plugn trigger install ;; https:* | git* | ssh:* | file:* | *.tar.gz | *.tgz) - shift download_and_enable_plugin "$@" plugn trigger install ;; @@ -25,4 +27,4 @@ plugin_install_cmd() { plugin_prime_bash_completion } -plugin_install_cmd "$@" +cmd-plugin-install "$@" diff --git a/plugins/plugin/subcommands/install-dependencies b/plugins/plugin/subcommands/install-dependencies index 9e9949b86..833df7225 100755 --- a/plugins/plugin/subcommands/install-dependencies +++ b/plugins/plugin/subcommands/install-dependencies @@ -2,13 +2,16 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -plugin_install_dependencies_cmd() { +cmd-plugin-install-dependencies() { declare desc="calls dependencies plugin trigger via command line" - local cmd="plugin:install-dependencies" - if [[ $2 == "--core" ]]; then + declare cmd="plugin:install-dependencies" + [[ "$1" == "$cmd" ]] && shift 1 + declare FLAG="$1" + + if [[ "$FLAG" == "--core" ]]; then export PLUGIN_PATH="$PLUGIN_CORE_PATH" fi plugn trigger dependencies } -plugin_install_dependencies_cmd "$@" +cmd-plugin-install-dependencies "$@" diff --git a/plugins/plugin/subcommands/list b/plugins/plugin/subcommands/list index fcdc1fd0f..0970a7b4e 100755 --- a/plugins/plugin/subcommands/list +++ b/plugins/plugin/subcommands/list @@ -3,4 +3,4 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions" -plugin_list_cmd "$@" +cmd-plugin-list "$@" diff --git a/plugins/plugin/subcommands/trigger b/plugins/plugin/subcommands/trigger index 94a58d78f..4255b874e 100755 --- a/plugins/plugin/subcommands/trigger +++ b/plugins/plugin/subcommands/trigger @@ -2,12 +2,12 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -plugin_trigger_cmd() { +cmd-plugin-trigger() { declare desc="trigger an arbitrary plugin hook" - local cmd="plugin:trigger" + declare cmd="plugin:trigger" [[ "$1" == "$cmd" ]] && shift 1 plugn trigger "$@" } -plugin_trigger_cmd "$@" +cmd-plugin-trigger "$@" diff --git a/plugins/plugin/subcommands/uninstall b/plugins/plugin/subcommands/uninstall index 66b246d5a..08d51cc56 100755 --- a/plugins/plugin/subcommands/uninstall +++ b/plugins/plugin/subcommands/uninstall @@ -5,13 +5,15 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions" -plugin_uninstall_cmd() { +cmd-plugin-uninstall() { declare desc="uninstalls plugin via command line" - local cmd="plugin:uninstall" - [[ -z $2 ]] && dokku_log_fail "Please specify a plugin to uninstall" - local PLUGIN="$2" + declare cmd="plugin:uninstall" + [[ "$1" == "$cmd" ]] && shift 1 + declare PLUGIN="$1" + + [[ -z "$PLUGIN" ]] && dokku_log_fail "Please specify a plugin to uninstall" uninstall_plugin "$PLUGIN" plugin_prime_bash_completion } -plugin_uninstall_cmd "$@" +cmd-plugin-uninstall "$@" diff --git a/plugins/plugin/subcommands/update b/plugins/plugin/subcommands/update index 529a1b015..366b09bb6 100755 --- a/plugins/plugin/subcommands/update +++ b/plugins/plugin/subcommands/update @@ -3,16 +3,17 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions" -plugin_update_cmd() { +cmd-plugin-update() { declare desc="updates plugin to optional committish and calls update plugin trigger via command line" - local cmd="plugin:update" - if [[ -n "$2" ]]; then - local PLUGIN="$2" - local PLUGIN_COMMITTISH="$3" + declare cmd="plugin:update" + [[ "$1" == "$cmd" ]] && shift 1 + declare PLUGIN="$1" PLUGIN_COMMITTISH="$2" + + if [[ -n "$PLUGIN" ]]; then plugn update "$PLUGIN" "$PLUGIN_COMMITTISH" fi plugn trigger update plugin_prime_bash_completion } -plugin_update_cmd "$@" +cmd-plugin-update "$@" diff --git a/plugins/proxy/commands b/plugins/proxy/commands index ebc2510b5..742fe187d 100755 --- a/plugins/proxy/commands +++ b/plugins/proxy/commands @@ -1,12 +1,12 @@ #!/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 case "$1" in help | proxy:help) - proxy_help_cmd "$@" + cmd-proxy-help "$@" ;; *) 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 70e8dbbd5..43f8e29b1 100755 --- a/plugins/proxy/internal-functions +++ b/plugins/proxy/internal-functions @@ -6,9 +6,10 @@ set -eo pipefail cmd-proxy-report() { declare desc="displays a proxy report for one or more apps" - local cmd="proxy:report" + declare cmd="proxy:report" + [[ "$1" == "$cmd" ]] && shift 1 local INSTALLED_APPS=$(dokku_apps) - local APP="$2" INFO_FLAG="$3" + local APP="$1" INFO_FLAG="$2" if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -75,36 +76,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 -} - -proxy_help_cmd() { - 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/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/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/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/internal-functions b/plugins/ps/internal-functions index ca775b8f9..8d863a87e 100755 --- a/plugins/ps/internal-functions +++ b/plugins/ps/internal-functions @@ -8,8 +8,9 @@ set -eo pipefail cmd-ps-inspect() { declare desc="displays a sanitized version of docker inspect for an app" - local cmd="ps:inspect" - local APP="$2" + declare cmd="ps:inspect" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" verify_app_name "$APP" local DOKKU_SCHEDULER=$(get_app_scheduler "$APP") @@ -18,9 +19,10 @@ cmd-ps-inspect() { cmd-ps-report() { declare desc="displays a ps report for one or more apps" - local cmd="ps:report" + declare cmd="ps: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/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/ps/subcommands/default b/plugins/ps/subcommands/default index 3f136c8d1..1df0fb262 100755 --- a/plugins/ps/subcommands/default +++ b/plugins/ps/subcommands/default @@ -3,14 +3,15 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -ps_main_cmd() { +cmd-ps-default() { declare desc="shows running processes in all running app containers" - local cmd="ps" + declare cmd="ps" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + dokku_log_warn "Deprecated: Please use ps:report" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - - local APP="$2" verify_app_name "$APP" ! (is_deployed "$APP") && dokku_log_warn "App $APP has not been deployed" && exit 0 @@ -25,4 +26,4 @@ ps_main_cmd() { done } -ps_main_cmd "$@" +cmd-ps-default "$@" diff --git a/plugins/ps/subcommands/rebuild b/plugins/ps/subcommands/rebuild index 47bb97f99..22d1ba2dd 100755 --- a/plugins/ps/subcommands/rebuild +++ b/plugins/ps/subcommands/rebuild @@ -4,10 +4,12 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_rebuild_cmd() { +cmd-ps-rebuild() { declare desc="rebuilds an app from source" - local cmd="ps:rebuild" - local APP="$2" + declare cmd="ps:rebuild" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" if (is_deployed "$APP"); then @@ -17,4 +19,4 @@ ps_rebuild_cmd() { fi } -ps_rebuild_cmd "$@" +cmd-ps-rebuild "$@" diff --git a/plugins/ps/subcommands/rebuildall b/plugins/ps/subcommands/rebuildall index 9390f1e0d..98fe32095 100755 --- a/plugins/ps/subcommands/rebuildall +++ b/plugins/ps/subcommands/rebuildall @@ -4,11 +4,12 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions" -ps_rebuildall_cmd() { +cmd-ps-rebuildall() { declare desc="rebuilds all apps from source" - local cmd="ps:rebuildall" + declare cmd="ps:rebuildall" + [[ "$1" == "$cmd" ]] && shift 1 fn-ps-parallel-cmd "rebuild" } -ps_rebuildall_cmd "$@" +cmd-ps-rebuildall "$@" diff --git a/plugins/ps/subcommands/restart b/plugins/ps/subcommands/restart index 85068e59c..cccb9ab1e 100755 --- a/plugins/ps/subcommands/restart +++ b/plugins/ps/subcommands/restart @@ -4,11 +4,14 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_restart_cmd() { +cmd-ps-restart() { declare desc="restarts app via command line" - local cmd="ps:restart" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - ps_restart "$2" + declare cmd="ps:restart" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + ps_restart "$APP" } -ps_restart_cmd "$@" +cmd-ps-restart "$@" diff --git a/plugins/ps/subcommands/restart-policy b/plugins/ps/subcommands/restart-policy index c1195f190..fe30684c5 100755 --- a/plugins/ps/subcommands/restart-policy +++ b/plugins/ps/subcommands/restart-policy @@ -5,15 +5,18 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_restart_policy_cmd() { +cmd-ps-restart-policy() { declare desc="shows the restart-policy for an app" - local cmd="ps:restart-policy" + declare cmd="ps:restart-policy" + [[ "$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_info2_quiet "$APP restart-policy:" get_restart_policies "$(get_phase_file_path "$passed_phases")" } -ps_restart_policy_cmd "$@" +cmd-ps-restart-policy "$@" diff --git a/plugins/ps/subcommands/restartall b/plugins/ps/subcommands/restartall index 07a8e2a53..cb9200e10 100755 --- a/plugins/ps/subcommands/restartall +++ b/plugins/ps/subcommands/restartall @@ -4,11 +4,12 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions" -ps_restartall_cmd() { +cmd-ps-restartall() { declare desc="restarts all apps via command line" - local cmd="ps:restartall" + declare cmd="ps:restartall" + [[ "$1" == "$cmd" ]] && shift 1 fn-ps-parallel-cmd "restart" } -ps_restartall_cmd "$@" +cmd-ps-restartall "$@" diff --git a/plugins/ps/subcommands/restore b/plugins/ps/subcommands/restore index d8b43b514..7d23c1148 100755 --- a/plugins/ps/subcommands/restore +++ b/plugins/ps/subcommands/restore @@ -6,10 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions" -ps_restore_cmd() { +cmd-ps-restore() { declare desc="starts all apps with DOKKU_APP_RESTORE not set to 0 via command line" - local cmd="ps:restore" - local APP="$2" + declare cmd="ps:restore" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" local DOKKU_SCHEDULER DOKKU_SCHEDULER=$(get_app_scheduler "$APP") @@ -30,4 +31,4 @@ ps_restore_cmd() { fi } -ps_restore_cmd "$@" +cmd-ps-restore "$@" diff --git a/plugins/ps/subcommands/retire b/plugins/ps/subcommands/retire index 4fb414940..d32e6b8af 100755 --- a/plugins/ps/subcommands/retire +++ b/plugins/ps/subcommands/retire @@ -4,9 +4,11 @@ set -eo pipefail source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -ps_retire_cmd() { +cmd-ps-retire() { declare desc="ensures old containers are retired" - local cmd="ps:retire" + declare cmd="ps:retire" + [[ "$1" == "$cmd" ]] && shift 1 + local LOCK_FILE="${DOKKU_LIB_ROOT}/data/ps/retire" local DOKKU_SCHEDULER=$(config_get "--global" DOKKU_SCHEDULER || echo "docker-local") @@ -15,4 +17,4 @@ ps_retire_cmd() { release_advisory_lock "$LOCK_FILE" } -ps_retire_cmd "$@" +cmd-ps-retire "$@" diff --git a/plugins/ps/subcommands/scale b/plugins/ps/subcommands/scale index 25b467068..5a5a6e4bc 100755 --- a/plugins/ps/subcommands/scale +++ b/plugins/ps/subcommands/scale @@ -4,12 +4,14 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_scale_cmd() { +cmd-ps-scale() { declare desc="sets app scaling config via command line" - local cmd="ps:scale" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - shift 1 + declare cmd="ps:scale" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" ps_scale "$@" } -ps_scale_cmd "$@" +cmd-ps-scale "$@" diff --git a/plugins/ps/subcommands/set-restart-policy b/plugins/ps/subcommands/set-restart-policy index bfb3bc044..b18495e2e 100755 --- a/plugins/ps/subcommands/set-restart-policy +++ b/plugins/ps/subcommands/set-restart-policy @@ -5,12 +5,14 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_set_restart_policy_cmd() { +cmd-ps-set-restart-policy() { declare desc="sets app restart-policy" - local cmd="ps:set-restart-policy" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - verify_app_name "$2" && local APP="$2" - local RESTART_POLICY="$3" + declare cmd="ps:set-restart-policy" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" RESTART_POLICY="$2" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$APP" local RE_RESTART_POLICY="^(no|unless-stopped|always|on-failure(:[1-9][0-9]*)?)$" if [[ ! "$RESTART_POLICY" =~ $RE_RESTART_POLICY ]]; then @@ -29,4 +31,4 @@ ps_set_restart_policy_cmd() { add_passed_docker_option passed_phases[@] "--restart=${RESTART_POLICY}" } -ps_set_restart_policy_cmd "$@" +cmd-ps-set-restart-policy "$@" diff --git a/plugins/ps/subcommands/start b/plugins/ps/subcommands/start index 5d276a9af..8be6cae51 100755 --- a/plugins/ps/subcommands/start +++ b/plugins/ps/subcommands/start @@ -4,11 +4,14 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_start_cmd() { +cmd-ps-start() { declare desc="starts app via command line" - local cmd="ps:start" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - ps_start "$2" + declare cmd="ps:start" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + ps_start "$APP" } -ps_start_cmd "$@" +cmd-ps-start "$@" diff --git a/plugins/ps/subcommands/startall b/plugins/ps/subcommands/startall index 0ccb7234c..69726033c 100755 --- a/plugins/ps/subcommands/startall +++ b/plugins/ps/subcommands/startall @@ -4,11 +4,12 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions" -ps_startall_cmd() { +cmd-ps-startall() { declare desc="starts all apps via command line" - local cmd="ps:startall" + declare cmd="ps:startall" + [[ "$1" == "$cmd" ]] && shift 1 fn-ps-parallel-cmd "start" } -ps_startall_cmd "$@" +cmd-ps-startall "$@" diff --git a/plugins/ps/subcommands/stop b/plugins/ps/subcommands/stop index 512570c6e..37c0fec66 100755 --- a/plugins/ps/subcommands/stop +++ b/plugins/ps/subcommands/stop @@ -4,11 +4,14 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_stop_cmd() { +cmd-ps-stop() { declare desc="stops app via command line" - local cmd="ps:stop" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - ps_stop "$2" + declare cmd="ps:stop" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" + ps_stop "$APP" } -ps_stop_cmd "$@" +cmd-ps-stop "$@" diff --git a/plugins/ps/subcommands/stopall b/plugins/ps/subcommands/stopall index decef1c98..f05be6a45 100755 --- a/plugins/ps/subcommands/stopall +++ b/plugins/ps/subcommands/stopall @@ -4,11 +4,12 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions" -ps_stopall_cmd() { +cmd-ps-stopall() { declare desc="stops all apps via command line" - local cmd="ps:stopall" + declare cmd="ps:stopall" + [[ "$1" == "$cmd" ]] && shift 1 fn-ps-parallel-cmd "stop" } -ps_stopall_cmd "$@" +cmd-ps-stopall "$@" 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/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/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/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/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/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/internal-functions b/plugins/scheduler-docker-local/internal-functions index 955f9b5df..5635742a3 100755 --- a/plugins/scheduler-docker-local/internal-functions +++ b/plugins/scheduler-docker-local/internal-functions @@ -7,9 +7,10 @@ set -eo pipefail cmd-scheduler-docker-local-report() { declare desc="displays a scheduler-docker-local report for one or more apps" - local cmd="scheduler-docker-local:report" + declare cmd="scheduler-docker-local: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" @@ -65,32 +66,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 </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/scheduler-docker-local/subcommands/default b/plugins/scheduler-docker-local/subcommands/default index b2258f10b..24bb628b1 100755 --- a/plugins/scheduler-docker-local/subcommands/default +++ b/plugins/scheduler-docker-local/subcommands/default @@ -1,6 +1,6 @@ #!/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" cmd-scheduler-docker-local-help "scheduler-docker-local:help" diff --git a/plugins/scheduler-docker-local/subcommands/set b/plugins/scheduler-docker-local/subcommands/set index b97c206a1..522162a6a 100755 --- a/plugins/scheduler-docker-local/subcommands/set +++ b/plugins/scheduler-docker-local/subcommands/set @@ -4,12 +4,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -scheduler-docker-local-set-cmd() { +cmd-scheduler-docker-local-set() { declare desc="set or clear a scheduler-docker-local property for an app" - local cmd="scheduler-docker-local:set" argv=("$@") - [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare cmd="scheduler-docker-local:set" + [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" KEY="$2" VALUE="$3" local VALID_KEYS=("disable-chown") + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" [[ -z "$KEY" ]] && dokku_log_fail "No key specified" @@ -26,4 +27,4 @@ scheduler-docker-local-set-cmd() { fi } -scheduler-docker-local-set-cmd "$@" +cmd-scheduler-docker-local-set "$@" diff --git a/plugins/shell/commands b/plugins/shell/commands index df45312ea..0212e53ae 100755 --- a/plugins/shell/commands +++ b/plugins/shell/commands @@ -1,29 +1,12 @@ #!/usr/bin/env bash [[ " help shell:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/shell/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in help | shell:help) - help_content_func() { - declare desc="return shell 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 +} diff --git a/plugins/ssh-keys/internal-functions b/plugins/ssh-keys/internal-functions deleted file mode 100755 index 818136cbe..000000000 --- a/plugins/ssh-keys/internal-functions +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash -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 -} - -ssh_keys_help_cmd() { - 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 </dev/null" RETURN INT TERM EXIT @@ -38,4 +39,4 @@ add_keys() { verify_ssh_key_file } -add_keys "$@" +cmd-ssh-keys-add "$@" diff --git a/plugins/ssh-keys/subcommands/default b/plugins/ssh-keys/subcommands/default index 1ee01b434..6b4601f48 100755 --- a/plugins/ssh-keys/subcommands/default +++ b/plugins/ssh-keys/subcommands/default @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_AVAILABLE_PATH/ssh-keys/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/ssh-keys/help-functions" -ssh_keys_help_cmd "ssh-keys:help" +cmd-ssh-keys-help "ssh-keys:help" diff --git a/plugins/ssh-keys/subcommands/list b/plugins/ssh-keys/subcommands/list index 853e98fc1..f3abd3803 100755 --- a/plugins/ssh-keys/subcommands/list +++ b/plugins/ssh-keys/subcommands/list @@ -4,4 +4,13 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" -list_ssh_keys "$@" +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/ssh-keys/subcommands/remove b/plugins/ssh-keys/subcommands/remove index 7f19b06a8..b8587bf52 100755 --- a/plugins/ssh-keys/subcommands/remove +++ b/plugins/ssh-keys/subcommands/remove @@ -4,14 +4,15 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" -remove_key() { +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 $?" } -remove_key "$@" +cmd-ssh-keys-remove "$@" diff --git a/plugins/storage/commands b/plugins/storage/commands index 459d53762..a3a329180 100755 --- a/plugins/storage/commands +++ b/plugins/storage/commands @@ -1,12 +1,12 @@ #!/usr/bin/env bash [[ " storage:help help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" -source "$PLUGIN_AVAILABLE_PATH/storage/internal-functions" +source "$PLUGIN_AVAILABLE_PATH/storage/help-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x case "$1" in help | storage:help) - storage_help_cmd "$@" + cmd-storage-help "$@" ;; *) diff --git a/plugins/storage/help-functions b/plugins/storage/help-functions new file mode 100755 index 000000000..b34df5296 --- /dev/null +++ b/plugins/storage/help-functions @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-storage-help() { + declare desc="help command" + declare CMD="$1" + local plugin_name="storage" + local plugin_description="Manage mounted volumes" + + 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 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/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/storage/internal-functions b/plugins/storage/internal-functions index 30b297143..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" @@ -75,39 +76,15 @@ 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 -} - -storage_help_cmd() { - 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/tags/subcommands/create b/plugins/tags/subcommands/create index 755a752d9..ea49d1506 100755 --- a/plugins/tags/subcommands/create +++ b/plugins/tags/subcommands/create @@ -4,15 +4,16 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -tags_create_cmd() { +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" @@ -20,4 +21,4 @@ tags_create_cmd() { plugn trigger tags-create "$APP" "$IMAGE_TAG" } -tags_create_cmd "$@" +cmd-tags-create "$@" diff --git a/plugins/tags/subcommands/default b/plugins/tags/subcommands/default index fd9272e1e..e740f5983 100755 --- a/plugins/tags/subcommands/default +++ b/plugins/tags/subcommands/default @@ -3,16 +3,18 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -tags_main_cmd() { +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" } -tags_main_cmd "$@" +cmd-tags-default "$@" diff --git a/plugins/tags/subcommands/deploy b/plugins/tags/subcommands/deploy index c87f7312c..227b0f30a 100755 --- a/plugins/tags/subcommands/deploy +++ b/plugins/tags/subcommands/deploy @@ -3,15 +3,16 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -tags_deploy_cmd() { +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" @@ -22,4 +23,4 @@ tags_deploy_cmd() { fi } -tags_deploy_cmd "$@" +cmd-tags-deploy "$@" diff --git a/plugins/tags/subcommands/destroy b/plugins/tags/subcommands/destroy index f23009b46..7a935948e 100755 --- a/plugins/tags/subcommands/destroy +++ b/plugins/tags/subcommands/destroy @@ -4,15 +4,16 @@ set -eo pipefail source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" -tags_destroy_cmd() { +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" @@ -26,4 +27,4 @@ tags_destroy_cmd() { plugn trigger tags-destroy "$APP" "$IMAGE_TAG" } -tags_destroy_cmd "$@" +cmd-tags-destroy "$@" diff --git a/plugins/tar/commands b/plugins/tar/commands index 9c29b3358..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) - tar_help_cmd "$1" + cmd-tar-help "$@" ;; *) 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 "$@" diff --git a/plugins/tar/functions b/plugins/tar/functions index ce5e73c26..a5b703d19 100755 --- a/plugins/tar/functions +++ b/plugins/tar/functions @@ -56,23 +56,25 @@ tar_trigger_build() { fi } -tar_in_cmd() { +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" } -tar_from_cmd() { +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/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 a21dadfd4..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 -} - -tar_help_cmd() { - 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 <"$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 } -trace_default_cmd "$@" +cmd-trace-default "$@" diff --git a/plugins/trace/subcommands/off b/plugins/trace/subcommands/off index a7f44c0eb..51b480582 100755 --- a/plugins/trace/subcommands/off +++ b/plugins/trace/subcommands/off @@ -3,13 +3,14 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -trace_off_cmd() { +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" } -trace_off_cmd "$@" +cmd-trace-off "$@" diff --git a/plugins/trace/subcommands/on b/plugins/trace/subcommands/on index 694791b16..aff884cff 100755 --- a/plugins/trace/subcommands/on +++ b/plugins/trace/subcommands/on @@ -3,13 +3,14 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -trace_on_cmd() { +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" } -trace_on_cmd "$@" +cmd-trace-on "$@" diff --git a/tests/unit/10_apps.bats b/tests/unit/10_apps.bats index ccb4bbf44..e9f714fb2 100644 --- a/tests/unit/10_apps.bats +++ b/tests/unit/10_apps.bats @@ -10,6 +10,13 @@ teardown() { global_teardown } +@test "(apps) apps:help" { + run /bin/bash -c "dokku apps:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage apps" +} + @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..25c9b5ab2 100644 --- a/tests/unit/10_certs.bats +++ b/tests/unit/10_certs.bats @@ -27,6 +27,13 @@ teardown() { global_teardown } +@test "(certs) certs:help" { + run /bin/bash -c "dokku certs:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage SSL (TLS) certs" +} + @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..10811ea8e 100644 --- a/tests/unit/10_checks.bats +++ b/tests/unit/10_checks.bats @@ -16,6 +16,13 @@ teardown() { global_teardown } +@test "(checks) checks:help" { + run /bin/bash -c "dokku checks:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage zero-downtime settings" +} + @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..11a935824 100644 --- a/tests/unit/10_ps-general.bats +++ b/tests/unit/10_ps-general.bats @@ -12,6 +12,13 @@ teardown() { global_teardown } +@test "(ps) ps:help" { + run /bin/bash -c "dokku ps:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage container processes" +} + @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..0d27f0c87 100644 --- a/tests/unit/20_config.bats +++ b/tests/unit/20_config.bats @@ -18,6 +18,13 @@ teardown() { global_teardown } +@test "(config) config:help" { + run /bin/bash -c "dokku config:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage global and app-specific config vars" +} + @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..63d0689bc 100644 --- a/tests/unit/20_docker-options.bats +++ b/tests/unit/20_docker-options.bats @@ -12,6 +12,13 @@ teardown() { global_teardown } +@test "(docker-options) docker-options:help" { + run /bin/bash -c "dokku docker-options:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker options for an app" +} + @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..91b7cd6f5 100644 --- a/tests/unit/20_domains.bats +++ b/tests/unit/20_domains.bats @@ -16,6 +16,13 @@ teardown() { global_teardown } +@test "(domains) domains:help" { + run /bin/bash -c "dokku domains:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage domains used by the proxy" +} + @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_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" } diff --git a/tests/unit/30_events.bats b/tests/unit/30_events.bats index 520e1fefe..65a3cc7e6 100644 --- a/tests/unit/30_events.bats +++ b/tests/unit/30_events.bats @@ -12,6 +12,13 @@ teardown() { global_teardown } +@test "(events) events:help" { + run /bin/bash -c "dokku events:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage event logging" +} + @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..4b082931a 100644 --- a/tests/unit/40_plugin.bats +++ b/tests/unit/40_plugin.bats @@ -24,6 +24,13 @@ teardown() { global_teardown } +@test "(plugin) plugin:help" { + run /bin/bash -c "dokku plugin:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage installed plugins" +} + @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..ed7bac817 100644 --- a/tests/unit/40_proxy.bats +++ b/tests/unit/40_proxy.bats @@ -41,6 +41,13 @@ assert_external_port() { fi } +@test "(proxy) proxy:help" { + run /bin/bash -c "dokku proxy:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the proxy integration for an app" +} + @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..4d0b41e21 100644 --- a/tests/unit/40_tags.bats +++ b/tests/unit/40_tags.bats @@ -12,6 +12,13 @@ teardown() { global_teardown } +@test "(tags) tags:help" { + run /bin/bash -c "dokku tags:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker image tags" +} + @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..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"