subcommand restructure and bashstyle refactor. closes #1579
This commit is contained in:
committed by
Michael Hobbs
parent
76e27f0333
commit
89f289b433
@@ -1,29 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " proxy proxy:set proxy:enable proxy:disable help proxy:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
[[ " help proxy: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/proxy/functions"
|
||||
|
||||
case "$1" in
|
||||
proxy)
|
||||
proxy_main "$2"
|
||||
;;
|
||||
|
||||
proxy:set)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
proxy_set "$2"
|
||||
;;
|
||||
|
||||
proxy:enable)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
proxy_enable "$2" --no-restart
|
||||
;;
|
||||
|
||||
proxy:disable)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
proxy_disable "$2" --no-restart
|
||||
;;
|
||||
|
||||
help | proxy:help)
|
||||
cat<<EOF
|
||||
proxy <app>, Show proxy for app
|
||||
|
||||
@@ -22,55 +22,3 @@ get_app_proxy_type() {
|
||||
|
||||
echo $APP_PROXY_TYPE
|
||||
}
|
||||
|
||||
proxy_main() {
|
||||
local desc="displays app proxy implementation"
|
||||
local ALL_APPS=$(dokku_apps)
|
||||
if [[ -n "$1" ]]; then
|
||||
local APP="$1"
|
||||
fi
|
||||
local APPS=${APP:="$ALL_APPS"}
|
||||
|
||||
dokku_col_log_info1_quiet "App Name" "Proxy Type"
|
||||
for app in $APPS; do
|
||||
verify_app_name "$app"
|
||||
dokku_col_log_msg "$app" "$(get_app_proxy_type "$app")"
|
||||
done
|
||||
}
|
||||
|
||||
proxy_set() {
|
||||
local desc="enable proxy for app"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
dokku_log_info1 "proxy:set not implemented"
|
||||
}
|
||||
|
||||
proxy_enable() {
|
||||
local desc="enable proxy for app"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
if [[ "$(is_app_proxy_enabled "$APP")" == "false" ]]; then
|
||||
dokku_log_info1 "Enabling proxy for app ($APP)"
|
||||
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
|
||||
# shellcheck disable=SC2086
|
||||
config_unset $CONFIG_SET_ARGS $APP DOKKU_DISABLE_PROXY
|
||||
plugn trigger proxy-enable "$APP"
|
||||
else
|
||||
dokku_log_info1 "proxy is already enabled for app ($APP)"
|
||||
fi
|
||||
}
|
||||
|
||||
proxy_disable() {
|
||||
local desc="disable proxy for app"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
if [[ "$(is_app_proxy_enabled "$APP")" == "true" ]]; then
|
||||
dokku_log_info1 "Disabling proxy for app ($APP)"
|
||||
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
|
||||
# shellcheck disable=SC2086
|
||||
config_set $CONFIG_SET_ARGS $APP DOKKU_DISABLE_PROXY=1
|
||||
plugn trigger proxy-disable "$APP"
|
||||
else
|
||||
dokku_log_info1 "proxy is already disable for app ($APP)"
|
||||
fi
|
||||
}
|
||||
|
||||
22
plugins/proxy/subcommands/default
Executable file
22
plugins/proxy/subcommands/default
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
|
||||
|
||||
proxy_main_cmd() {
|
||||
local desc="displays app proxy implementation via command line"
|
||||
local cmd="proxy"
|
||||
local ALL_APPS=$(dokku_apps)
|
||||
if [[ -n "$2" ]]; then
|
||||
local APP="$2"
|
||||
fi
|
||||
local APPS=${APP:="$ALL_APPS"}
|
||||
|
||||
dokku_col_log_info1_quiet "App Name" "Proxy Type"
|
||||
for app in $APPS; do
|
||||
verify_app_name "$app"
|
||||
dokku_col_log_msg "$app" "$(get_app_proxy_type "$app")"
|
||||
done
|
||||
}
|
||||
|
||||
proxy_main_cmd "$@"
|
||||
24
plugins/proxy/subcommands/disable
Executable file
24
plugins/proxy/subcommands/disable
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
|
||||
|
||||
proxy_disable_cmd() {
|
||||
local desc="disable proxy for app via command line"
|
||||
local cmd="proxy:disable"
|
||||
[[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
if [[ "$(is_app_proxy_enabled "$APP")" == "true" ]]; then
|
||||
dokku_log_info1 "Disabling proxy for app ($APP)"
|
||||
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
|
||||
# shellcheck disable=SC2086
|
||||
config_set $CONFIG_SET_ARGS $APP DOKKU_DISABLE_PROXY=1
|
||||
plugn trigger proxy-disable "$APP"
|
||||
else
|
||||
dokku_log_info1 "proxy is already disable for app ($APP)"
|
||||
fi
|
||||
}
|
||||
|
||||
proxy_disable_cmd "$2" --no-restart
|
||||
24
plugins/proxy/subcommands/enable
Executable file
24
plugins/proxy/subcommands/enable
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
|
||||
|
||||
proxy_enable_cmd() {
|
||||
local desc="enable proxy for app via command line"
|
||||
local cmd="proxy:enable"
|
||||
[[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
if [[ "$(is_app_proxy_enabled "$APP")" == "false" ]]; then
|
||||
dokku_log_info1 "Enabling proxy for app ($APP)"
|
||||
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
|
||||
# shellcheck disable=SC2086
|
||||
config_unset $CONFIG_SET_ARGS $APP DOKKU_DISABLE_PROXY
|
||||
plugn trigger proxy-enable "$APP"
|
||||
else
|
||||
dokku_log_info1 "proxy is already enabled for app ($APP)"
|
||||
fi
|
||||
}
|
||||
|
||||
proxy_enable_cmd "$2" --no-restart
|
||||
14
plugins/proxy/subcommands/set
Executable file
14
plugins/proxy/subcommands/set
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
proxy_set_cmd() {
|
||||
local desc="enable proxy for app via command line"
|
||||
local cmd="proxy:set"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
|
||||
local APP="$2"; verify_app_name "$APP"
|
||||
dokku_log_info1 "proxy:set not implemented"
|
||||
}
|
||||
|
||||
proxy_set_cmd "$@"
|
||||
Reference in New Issue
Block a user