initial pass at implementing DOKKU_PROXY_PORT_MAP. closes #2239.
This commit is contained in:
@@ -7,10 +7,14 @@ case "$1" in
|
||||
help_content_func () {
|
||||
declare desc="return proxy plugin help content"
|
||||
cat<<help_content
|
||||
proxy <app>, Show proxy for app
|
||||
proxy <app>, Show proxy settings for app
|
||||
proxy:enable <app>, Enable proxy for app
|
||||
proxy:disable <app>, Disable proxy for app
|
||||
proxy:set <app> <proxy_type>, NOT IMPLEMENTED YET!!
|
||||
proxy:ports <app>, List proxy port mappings for app
|
||||
proxy:ports-clear <app>, Clear all proxy port mappings for app
|
||||
proxy:ports-add <app> <scheme>:<host-port>:<container-port> [<scheme>:<host-port>:<container-port>...], Set proxy port mappings for app
|
||||
proxy:ports-remove <app> <host-port> [<host-port>...], Unset proxy port mappings for app
|
||||
proxy:set <app> <proxy-type>, Set proxy type for app
|
||||
help_content
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ is_app_proxy_enabled() {
|
||||
get_app_proxy_type() {
|
||||
declare desc="return app proxy type"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local APP_PROXY_TYPE="nginx"
|
||||
local DOKKU_APP_PROXY_TYPE="$(config_get "$APP" DOKKU_APP_PROXY_TYPE || true)"
|
||||
local APP_PROXY_TYPE="${DOKKU_APP_PROXY_TYPE:-nginx}"
|
||||
|
||||
echo $APP_PROXY_TYPE
|
||||
echo "$APP_PROXY_TYPE"
|
||||
}
|
||||
|
||||
24
plugins/proxy/subcommands/ports
Executable file
24
plugins/proxy/subcommands/ports
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"
|
||||
|
||||
proxy_ports_cmd() {
|
||||
declare desc="list proxy port mappings for an app"
|
||||
local cmd="proxy:ports"
|
||||
local APP="$2"; verify_app_name "$APP"
|
||||
local PROXY_PORT_MAP="$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)"
|
||||
|
||||
if [[ -n "$PROXY_PORT_MAP" ]]; then
|
||||
dokku_log_info1_quiet "Port mappings for $APP"
|
||||
dokku_col_log_info1_quiet "scheme" "host port" "container port"
|
||||
local port_map
|
||||
for port_map in $PROXY_PORT_MAP; do
|
||||
dokku_col_log_msg "$(cut -d ':' -f1 <<< "$port_map")" "$(cut -d ':' -f2 <<< "$port_map")" "$(cut -d ':' -f3 <<< "$port_map")"
|
||||
done
|
||||
else
|
||||
dokku_log_fail "No port mappings configured for app ($APP)"
|
||||
fi
|
||||
}
|
||||
|
||||
proxy_ports_cmd "$@"
|
||||
24
plugins/proxy/subcommands/ports-add
Executable file
24
plugins/proxy/subcommands/ports-add
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"
|
||||
|
||||
proxy_ports_add_cmd() {
|
||||
declare desc="add proxy port mappings from an app"
|
||||
local cmd="proxy:add"
|
||||
local APP="$2"; verify_app_name "$APP"
|
||||
local PROXY_PORT_MAP="$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)"
|
||||
shift 2
|
||||
|
||||
local INPUT_PORTS="$*"
|
||||
if [[ -n "$INPUT_PORTS" ]]; then
|
||||
PROXY_PORT_MAP="$(merge_dedupe_list "$PROXY_PORT_MAP $INPUT_PORTS" " ")"
|
||||
config_set --no-restart "$APP" DOKKU_PROXY_PORT_MAP="$PROXY_PORT_MAP"
|
||||
else
|
||||
dokku proxy:help
|
||||
dokku_log_fail "No port mapping specified. Exiting..."
|
||||
fi
|
||||
plugn trigger post-proxy-ports-update "$APP" "add"
|
||||
}
|
||||
|
||||
proxy_ports_add_cmd "$@"
|
||||
15
plugins/proxy/subcommands/ports-clear
Executable file
15
plugins/proxy/subcommands/ports-clear
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
proxy_ports_clear_cmd() {
|
||||
declare desc="clear all proxy port mappings for an app"
|
||||
local cmd="proxy:clear"
|
||||
local APP="$2"; verify_app_name "$APP"
|
||||
|
||||
config_unset --no-restart "$APP" DOKKU_PROXY_PORT_MAP
|
||||
plugn trigger post-proxy-ports-update "$APP" "clear"
|
||||
}
|
||||
|
||||
proxy_ports_clear_cmd "$@"
|
||||
34
plugins/proxy/subcommands/ports-remove
Executable file
34
plugins/proxy/subcommands/ports-remove
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
proxy_ports_remove_cmd() {
|
||||
declare desc="remove specific proxy port mappings from an app"
|
||||
local cmd="proxy:ports-remove"
|
||||
local APP="$2"; verify_app_name "$APP"
|
||||
local PROXY_PORT_MAP="$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)"
|
||||
shift 2
|
||||
|
||||
local INPUT_PORTS="$*"
|
||||
if [[ -n "$INPUT_PORTS" ]]; then
|
||||
local port
|
||||
for port in $INPUT_PORTS; do
|
||||
PROXY_PORT_MAP="$(sed -r "s/[[:alnum:]]+:$port:[[:alnum:]]+//g" <<< "$PROXY_PORT_MAP")"
|
||||
done
|
||||
PROXY_PORT_MAP="$(echo "$PROXY_PORT_MAP" | xargs)"
|
||||
PROXY_PORT_MAP="$(merge_dedupe_list "$PROXY_PORT_MAP" " ")"
|
||||
if [[ -n "$PROXY_PORT_MAP" ]]; then
|
||||
config_set --no-restart "$APP" DOKKU_PROXY_PORT_MAP="$PROXY_PORT_MAP"
|
||||
else
|
||||
config_unset --no-restart "$APP" DOKKU_PROXY_PORT_MAP
|
||||
fi
|
||||
plugn trigger post-proxy-ports-update "$APP" "remove"
|
||||
else
|
||||
dokku_log_warn "No port mapping specified. Please supply a valid configured host port"
|
||||
dokku proxy:ports "$APP"
|
||||
dokku_log_fail "exiting..."
|
||||
fi
|
||||
}
|
||||
|
||||
proxy_ports_remove_cmd "$@"
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
proxy_set_cmd() {
|
||||
declare desc="enable proxy for app via command line"
|
||||
@@ -8,7 +9,13 @@ proxy_set_cmd() {
|
||||
[[ -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"
|
||||
local PROXY_TYPE="$3"
|
||||
|
||||
if [[ -n "$PROXY_TYPE" ]]; then
|
||||
config_set --no-restart "$APP" DOKKU_APP_PROXY_TYPE="$PROXY_TYPE"
|
||||
else
|
||||
dokku_log_fail "Please specify a proxy type!"
|
||||
fi
|
||||
}
|
||||
|
||||
proxy_set_cmd "$@"
|
||||
|
||||
Reference in New Issue
Block a user