subcommand restructure and bashstyle refactor. closes #1579
This commit is contained in:
committed by
Michael Hobbs
parent
76e27f0333
commit
89f289b433
@@ -1,66 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " plugin plugin:install plugin:install-dependencies plugin:update plugin:disable plugin:enable plugin:uninstall help plugin:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
[[ " help plugin:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/plugin/functions"
|
||||
|
||||
case "$1" in
|
||||
plugin)
|
||||
plugn version
|
||||
plugn list
|
||||
;;
|
||||
|
||||
plugin:install)
|
||||
case "$2" in
|
||||
--core)
|
||||
[[ "$#" -gt 2 ]] && 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:*)
|
||||
shift
|
||||
download_and_enable_plugin "$@"
|
||||
plugn trigger install
|
||||
;;
|
||||
*)
|
||||
plugn trigger install
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
plugin:install-dependencies)
|
||||
if [[ $2 == "--core" ]]; then
|
||||
export PLUGIN_PATH="$PLUGIN_CORE_PATH"
|
||||
fi
|
||||
plugn trigger dependencies
|
||||
;;
|
||||
|
||||
plugin:update)
|
||||
if [[ -n "$2" ]]; then
|
||||
PLUGIN="$2"
|
||||
PLUGIN_COMMITTISH="$3"
|
||||
plugn update "$PLUGIN" "$PLUGIN_COMMITTISH"
|
||||
fi
|
||||
plugn trigger update
|
||||
;;
|
||||
|
||||
plugin:disable)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to disable"
|
||||
PLUGIN="$2"
|
||||
disable_plugin "$PLUGIN"
|
||||
;;
|
||||
|
||||
plugin:enable)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable"
|
||||
PLUGIN="$2"
|
||||
enable_plugin "$PLUGIN"
|
||||
;;
|
||||
|
||||
plugin:uninstall)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable"
|
||||
PLUGIN="$2"
|
||||
uninstall_plugin "$PLUGIN"
|
||||
;;
|
||||
|
||||
help | plugin:help)
|
||||
cat<<EOF
|
||||
plugin, Print active plugins
|
||||
|
||||
@@ -3,6 +3,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
disable_plugin() {
|
||||
local desc="disables specified plugin name"
|
||||
local PLUGIN="$1"
|
||||
[[ -e $PLUGIN_CORE_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Cannot disable a core plugin"
|
||||
[[ ! -e $PLUGIN_ENABLED_PATH/$PLUGIN ]] && dokku_log_fail "Plugin already disabled"
|
||||
@@ -12,6 +13,7 @@ disable_plugin() {
|
||||
}
|
||||
|
||||
enable_plugin() {
|
||||
local desc="enables specified plugin name"
|
||||
local PLUGIN="$1"
|
||||
[[ -e $PLUGIN_ENABLED_PATH/$PLUGIN ]] && dokku_log_fail "Plugin already enabled"
|
||||
[[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin does not exist"
|
||||
@@ -20,12 +22,14 @@ enable_plugin() {
|
||||
}
|
||||
|
||||
download_plugin() {
|
||||
local desc="download plugin from URL and set name"
|
||||
local PLUGIN_GIT_URL="$1"
|
||||
local PLUGIN_NAME="$2"
|
||||
plugn install "$PLUGIN_GIT_URL" "$PLUGIN_NAME"
|
||||
}
|
||||
|
||||
download_and_enable_plugin() {
|
||||
local desc="wrapper to download and enable specified version of plugin"
|
||||
local PLUGIN_GIT_URL="$1"
|
||||
shift
|
||||
while getopts ":-:" opt "$@"; do
|
||||
@@ -54,6 +58,7 @@ download_and_enable_plugin() {
|
||||
}
|
||||
|
||||
update_plugin() {
|
||||
local desc="update plugin"
|
||||
local PLUGIN="$1"
|
||||
local PLUGIN_COMMITTISH="$2"
|
||||
[[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin ($PLUGIN) is not currently installed"
|
||||
@@ -61,6 +66,7 @@ update_plugin() {
|
||||
}
|
||||
|
||||
uninstall_plugin() {
|
||||
local desc="uninstall plugin"
|
||||
local PLUGIN="$1"
|
||||
[[ -e $PLUGIN_CORE_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Cannot uninstall a core plugin"
|
||||
[[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin ($PLUGIN) is not currently installed"
|
||||
@@ -69,6 +75,7 @@ uninstall_plugin() {
|
||||
}
|
||||
|
||||
plugin_name() {
|
||||
local desc="default plugin name"
|
||||
local PLUGIN_GIT_URL="$1"
|
||||
echo "$PLUGIN_GIT_URL" | awk -F '/' '{ print $NF }' | sed -e "s:.git::g" | sed 's:^dokku-::'
|
||||
}
|
||||
|
||||
11
plugins/plugin/subcommands/default
Executable file
11
plugins/plugin/subcommands/default
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
plugin_main_cmd() {
|
||||
local desc="shows details about locally installed plugins"
|
||||
local cmd="plugin"
|
||||
plugn version
|
||||
plugn list
|
||||
}
|
||||
|
||||
plugin_main_cmd "$@"
|
||||
14
plugins/plugin/subcommands/disable
Executable file
14
plugins/plugin/subcommands/disable
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/plugin/functions"
|
||||
|
||||
plugin_disable_cmd() {
|
||||
local desc="disables plugin via command line"
|
||||
local cmd="plugin:disable"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to disable"
|
||||
local PLUGIN="$2"
|
||||
disable_plugin "$PLUGIN"
|
||||
}
|
||||
|
||||
plugin_disable_cmd "$@"
|
||||
14
plugins/plugin/subcommands/enable
Executable file
14
plugins/plugin/subcommands/enable
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/plugin/functions"
|
||||
|
||||
plugin_enable_cmd() {
|
||||
local desc="enables plugin via command line"
|
||||
local cmd="plugin:enable"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable"
|
||||
local PLUGIN="$2"
|
||||
enable_plugin "$PLUGIN"
|
||||
}
|
||||
|
||||
plugin_enable_cmd "$@"
|
||||
25
plugins/plugin/subcommands/install
Executable file
25
plugins/plugin/subcommands/install
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/plugin/functions"
|
||||
|
||||
plugin_install_cmd() {
|
||||
local desc="installs a plugin from URL and calls install plugin trigger via command line"
|
||||
local cmd="plugin:install"
|
||||
case "$2" in
|
||||
--core)
|
||||
[[ "$#" -gt 2 ]] && 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:*)
|
||||
shift
|
||||
download_and_enable_plugin "$@"
|
||||
plugn trigger install
|
||||
;;
|
||||
*)
|
||||
plugn trigger install
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
plugin_install_cmd "$@"
|
||||
13
plugins/plugin/subcommands/install-dependencies
Executable file
13
plugins/plugin/subcommands/install-dependencies
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
plugin_install_dependencies_cmd() {
|
||||
local desc="calls dependencies plugin trigger via command line"
|
||||
local cmd="plugin:install-dependencies"
|
||||
if [[ $2 == "--core" ]]; then
|
||||
export PLUGIN_PATH="$PLUGIN_CORE_PATH"
|
||||
fi
|
||||
plugn trigger dependencies
|
||||
}
|
||||
|
||||
plugin_install_dependencies_cmd "$@"
|
||||
14
plugins/plugin/subcommands/uninstall
Executable file
14
plugins/plugin/subcommands/uninstall
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/plugin/functions"
|
||||
|
||||
plugin_uninstall_cmd() {
|
||||
local desc="uninstalls plugin via command line"
|
||||
local cmd="plugin:uninstall"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable"
|
||||
local PLUGIN="$2"
|
||||
uninstall_plugin "$PLUGIN"
|
||||
}
|
||||
|
||||
plugin_uninstall_cmd "$@"
|
||||
15
plugins/plugin/subcommands/update
Executable file
15
plugins/plugin/subcommands/update
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
plugin_update_cmd() {
|
||||
local 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"
|
||||
plugn update "$PLUGIN" "$PLUGIN_COMMITTISH"
|
||||
fi
|
||||
plugn trigger update
|
||||
}
|
||||
|
||||
plugin_update_cmd "$@"
|
||||
Reference in New Issue
Block a user