make proxy port listing a callable function
This commit is contained in:
1 parent
2b19881f01
commit
21d0859253
3 files changed
+22
-13
No files matched your search
@@ -23,3 +23,20 @@ get_app_proxy_type() {
|
|||||||
|
|
||||||
echo "$APP_PROXY_TYPE"
|
echo "$APP_PROXY_TYPE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_app_proxy_ports() {
|
||||||
|
declare desc="list proxy port mappings for an app"
|
||||||
|
local APP="$1"; 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
|
||||||
|
}
|
||||||
@@ -1,24 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/proxy/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
proxy_ports_cmd() {
|
proxy_ports_cmd() {
|
||||||
declare desc="list proxy port mappings for an app"
|
declare desc="cmd wrapper to list proxy port mappings for an app"
|
||||||
local cmd="proxy:ports"
|
local cmd="proxy:ports"
|
||||||
local APP="$2"; verify_app_name "$APP"
|
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
|
list_app_proxy_ports "$APP"
|
||||||
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 "$@"
|
proxy_ports_cmd "$@"
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/proxy/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
proxy_ports_remove_cmd() {
|
proxy_ports_remove_cmd() {
|
||||||
@@ -26,7 +27,7 @@ proxy_ports_remove_cmd() {
|
|||||||
plugn trigger post-proxy-ports-update "$APP" "remove"
|
plugn trigger post-proxy-ports-update "$APP" "remove"
|
||||||
else
|
else
|
||||||
dokku_log_warn "No port mapping specified. Please supply a valid configured host port"
|
dokku_log_warn "No port mapping specified. Please supply a valid configured host port"
|
||||||
dokku proxy:ports "$APP"
|
list_app_proxy_ports "$APP"
|
||||||
dokku_log_fail "exiting..."
|
dokku_log_fail "exiting..."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user