From 7bbad9f074ea067cad52b4f3ad601835c0dac480 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Mar 2017 21:24:25 -0600 Subject: [PATCH 01/11] fix: ensure the help output for nginx/ssh-keys renders correctly Closes #2627 [ci skip] --- plugins/nginx-vhosts/subcommands/default | 2 +- plugins/ssh-keys/subcommands/default | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/nginx-vhosts/subcommands/default b/plugins/nginx-vhosts/subcommands/default index 5a4deae9b..08be1d5e9 100755 --- a/plugins/nginx-vhosts/subcommands/default +++ b/plugins/nginx-vhosts/subcommands/default @@ -2,4 +2,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions" -nginx_vhosts_help_cmd "$@" +nginx_vhosts_help_cmd "nginx:help" diff --git a/plugins/ssh-keys/subcommands/default b/plugins/ssh-keys/subcommands/default index 20fea35c3..2260f6e62 100755 --- a/plugins/ssh-keys/subcommands/default +++ b/plugins/ssh-keys/subcommands/default @@ -2,4 +2,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/ssh-keys/internal-functions" -ssh_keys_help_cmd "$@" +ssh_keys_help_cmd "ssh-keys:help" From 2bcad2014bdfa469c9fbf2a4f53040c86da396ce Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Mar 2017 21:26:19 -0600 Subject: [PATCH 02/11] chore: unify error output when an app is not declared --- docs/development/plugin-creation.md | 4 ++-- plugins/common/functions | 2 +- plugins/nginx-vhosts/subcommands/access-logs | 2 +- plugins/nginx-vhosts/subcommands/build-config | 2 +- plugins/storage/functions | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 2a2134082..b8d5e1b8d 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -30,7 +30,7 @@ hello_main_cmd() { set -- $cmd $@ ## - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" local APP="$2"; @@ -58,7 +58,7 @@ hello_world_cmd() { set -- $cmd $@ ## - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" local APP="$2"; diff --git a/plugins/common/functions b/plugins/common/functions index 20cb21c46..86278277f 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -530,7 +530,7 @@ dokku_deploy_cmd() { source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" - [[ -z $1 ]] && dokku_log_fail "Please specify an app to deploy" + [[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on" local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG") verify_app_name "$APP" plugn trigger pre-deploy "$APP" "$IMAGE_TAG" diff --git a/plugins/nginx-vhosts/subcommands/access-logs b/plugins/nginx-vhosts/subcommands/access-logs index 5b8fa8990..055d84713 100755 --- a/plugins/nginx-vhosts/subcommands/access-logs +++ b/plugins/nginx-vhosts/subcommands/access-logs @@ -7,7 +7,7 @@ source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" nginx_logs_cmd() { declare desc="display app nginx logs from command line" local cmd="$1" - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" nginx_logs "$@" } diff --git a/plugins/nginx-vhosts/subcommands/build-config b/plugins/nginx-vhosts/subcommands/build-config index 212c8ef15..74b118da2 100755 --- a/plugins/nginx-vhosts/subcommands/build-config +++ b/plugins/nginx-vhosts/subcommands/build-config @@ -7,7 +7,7 @@ source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" nginx_build_config_cmd() { declare desc="build nginx config to proxy app containers from command line" local cmd="nginx:build-config" - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" nginx_build_config "$2" } diff --git a/plugins/storage/functions b/plugins/storage/functions index d65daeb26..6d2ec0a6c 100755 --- a/plugins/storage/functions +++ b/plugins/storage/functions @@ -6,7 +6,7 @@ storage_list_cmd() { declare desc="List all bound mounts" local cmd="storage:list" local passed_phases="deploy" - [[ ! $2 ]] && dokku_log_fail "storage:list requires an app to list." + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" && local APP="$2" echo "$APP volume bind-mounts:" get_bind_mounts "$(get_phase_file_path "$passed_phases")" From 6124f2693bf4e630b4ab258593221e21c054deb3 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Mar 2017 21:26:46 -0600 Subject: [PATCH 03/11] feat: make plugin:default an alias of plugin:list --- plugins/plugin/commands | 2 +- plugins/plugin/internal-functions | 10 ++++++++++ plugins/plugin/subcommands/default | 12 ++++-------- plugins/plugin/subcommands/list | 5 +++++ 4 files changed, 20 insertions(+), 9 deletions(-) create mode 100755 plugins/plugin/internal-functions create mode 100755 plugins/plugin/subcommands/list diff --git a/plugins/plugin/commands b/plugins/plugin/commands index a5b4dff78..7f4164239 100755 --- a/plugins/plugin/commands +++ b/plugins/plugin/commands @@ -7,7 +7,7 @@ case "$1" in help_content_func () { declare desc="return plugin plugin help content" cat< Date: Sun, 12 Mar 2017 21:26:54 -0600 Subject: [PATCH 04/11] chore: formatting --- plugins/ssh-keys/internal-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/ssh-keys/internal-functions b/plugins/ssh-keys/internal-functions index bc4d868e7..e4bff023f 100755 --- a/plugins/ssh-keys/internal-functions +++ b/plugins/ssh-keys/internal-functions @@ -2,8 +2,8 @@ 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 From ef9b453aa84a56fde4ffe0287ae3592152861e73 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Mar 2017 21:27:21 -0600 Subject: [PATCH 05/11] refactor: mark storage:list as deprecated --- plugins/storage/subcommands/default | 3 ++- plugins/storage/subcommands/list | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) mode change 100644 => 100755 plugins/storage/subcommands/default diff --git a/plugins/storage/subcommands/default b/plugins/storage/subcommands/default old mode 100644 new mode 100755 index 194ef7942..f37200047 --- a/plugins/storage/subcommands/default +++ b/plugins/storage/subcommands/default @@ -2,11 +2,12 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" -source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" storage_main_cmd() { declare desc="an alias for storage:list" local cmd="storage" + + dokku_log_warn "Deprecated: Please use storage:list" storage_list_cmd "$@" } diff --git a/plugins/storage/subcommands/list b/plugins/storage/subcommands/list index a16999a38..ca27076b3 100755 --- a/plugins/storage/subcommands/list +++ b/plugins/storage/subcommands/list @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" -source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" storage_list_cmd "$@" From 48503e9f4066212083ec45fff53d76db98a3e2a6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Mar 2017 21:28:29 -0600 Subject: [PATCH 06/11] fix: add missing import --- plugins/storage/functions | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/storage/functions b/plugins/storage/functions index 6d2ec0a6c..1183fc57c 100755 --- a/plugins/storage/functions +++ b/plugins/storage/functions @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" storage_list_cmd() { declare desc="List all bound mounts" From 0153bc49bcb1f16e9d35925954f306daaee7f98c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Mar 2017 21:28:45 -0600 Subject: [PATCH 07/11] feat: create tar:default alias for tar:help --- plugins/tar/commands | 20 ++------------------ plugins/tar/internal-functions | 27 +++++++++++++++++++++++++++ plugins/tar/subcommands/default | 5 +++++ 3 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 plugins/tar/internal-functions create mode 100755 plugins/tar/subcommands/default diff --git a/plugins/tar/commands b/plugins/tar/commands index 60a8123a5..50fb131fb 100755 --- a/plugins/tar/commands +++ b/plugins/tar/commands @@ -1,27 +1,11 @@ #!/usr/bin/env bash [[ " help tar:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/tar/internal-functions" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | tar:help) - 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 - } - - 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:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + tar_help_cmd "$1" ;; *) diff --git a/plugins/tar/internal-functions b/plugins/tar/internal-functions new file mode 100644 index 000000000..1d81df165 --- /dev/null +++ b/plugins/tar/internal-functions @@ -0,0 +1,27 @@ +#!/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< Date: Sun, 12 Mar 2017 21:29:01 -0600 Subject: [PATCH 08/11] feat: create repo:default alias for repo:help --- plugins/repo/commands | 20 ++------------------ plugins/repo/internal-functions | 27 +++++++++++++++++++++++++++ plugins/repo/subcommands/default | 5 +++++ 3 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 plugins/repo/internal-functions create mode 100755 plugins/repo/subcommands/default diff --git a/plugins/repo/commands b/plugins/repo/commands index 816768bf3..c261c436b 100755 --- a/plugins/repo/commands +++ b/plugins/repo/commands @@ -1,27 +1,11 @@ #!/usr/bin/env bash [[ " help repo:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/repo/internal-functions" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | repo:help) - help_content_func () { - declare desc="return repo plugin help content" - cat<, Runs 'git gc --aggressive' against the application's repo - repo:purge-cache , Deletes the contents of the build cache stored in the repository -help_content - } - - if [[ $1 = "repo:help" ]] ; then - echo -e 'Usage: dokku repo[:COMMAND]' - echo '' - echo "Runs commands that interact with the app's repo" - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + repo_help_cmd "$@" ;; *) diff --git a/plugins/repo/internal-functions b/plugins/repo/internal-functions new file mode 100644 index 000000000..f58becc18 --- /dev/null +++ b/plugins/repo/internal-functions @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +repo_help_content_func () { + declare desc="return repo plugin help content" + cat<, Runs 'git gc --aggressive' against the application's repo + repo:purge-cache , Deletes the contents of the build cache stored in the repository +help_content +} + +repo_help_cmd() { + if [[ $1 = "repo:help" ]] ; then + echo -e 'Usage: dokku repo[:COMMAND]' + echo '' + echo "Runs commands that interact with the app's repo" + echo '' + echo 'Additional commands:' + repo_help_content_func | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + repo_help_content_func + else + cat< Date: Sun, 12 Mar 2017 21:29:12 -0600 Subject: [PATCH 09/11] feat: mark ps:default command as deprecated --- plugins/ps/subcommands/default | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/ps/subcommands/default b/plugins/ps/subcommands/default index bcb52434d..07f044d57 100755 --- a/plugins/ps/subcommands/default +++ b/plugins/ps/subcommands/default @@ -5,6 +5,8 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" ps_main_cmd() { declare desc="shows running processes in all running app containers" local cmd="ps" + dokku_log_warn "Deprecated: Please use ps:report" + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" local APP="$2"; verify_app_name "$APP" From 30bf228dc971fae6de4899b8cd5e40c30bb45a1f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Mar 2017 21:29:25 -0600 Subject: [PATCH 10/11] docs: swap in plugin:list command --- docs/advanced-usage/plugin-management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced-usage/plugin-management.md b/docs/advanced-usage/plugin-management.md index 3ac658310..b61ce2543 100644 --- a/docs/advanced-usage/plugin-management.md +++ b/docs/advanced-usage/plugin-management.md @@ -3,11 +3,11 @@ > New as of 0.4.0 ``` -plugin # Print active plugins plugin:disable # 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: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 ``` From 3c5335056c041538a340158fefde3aeb55e742ac Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Mar 2017 21:46:58 -0600 Subject: [PATCH 11/11] feat: allow plugin:help and plugin:list subcommands to be run without root --- dokku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dokku b/dokku index 978d617f4..c663b240a 100755 --- a/dokku +++ b/dokku @@ -56,7 +56,7 @@ if [[ $(id -un) != "dokku" ]] && [[ ! $1 =~ plugin:* ]] && [[ ! $1 == "ssh-keys: exit $? fi -if [[ $(id -un) != "root" && $1 =~ ^plugin:.* ]] || [[ $(id -un) != "root" && $1 == "ssh-keys:add" ]]; then +if [[ $(id -un) != "root" && $1 =~ ^plugin:.* && $1 != "plugin:help" && $1 != "plugin:list" ]] || [[ $(id -un) != "root" && $1 == "ssh-keys:add" ]]; then dokku_log_fail "This command must be run as root" fi