refactor: move code for fetching an available port to the ports plugin

Also translate the code to golang.
This commit is contained in:
Jose Diaz-Gonzalez committed 2023-08-05 10:58:57 -04:00
1 parent 121e4737a8
commit 192f7cf768
9 files changed
+59 -16

No files matched your search

+3 -3
View File
@@ -8,7 +8,7 @@ trigger-ports-proxy-configure-ports() {
declare desc="ports proxy-configure-ports plugin trigger"
declare trigger="proxy-configure-ports"
declare APP="$1"
local RAW_TCP_PORTS="$(get_app_raw_tcp_ports "$APP")"
local RAW_TCP_PORTS="$(plugn trigger ports-dockerfile-raw-tcp-ports "$APP" | xargs)"
local DOKKU_PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
local DOKKU_PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
local DOKKU_PROXY_PORT_MAP=$(config_get "$APP" DOKKU_PROXY_PORT_MAP)
@@ -20,7 +20,7 @@ trigger-ports-proxy-configure-ports() {
if [[ -z "$DOKKU_PROXY_PORT" ]] && [[ -z "$RAW_TCP_PORTS" ]]; then
if [[ "$IS_APP_VHOST_ENABLED" == "false" ]]; then
dokku_log_info1 "No port set, setting to random open high port"
local PROXY_PORT=$(get_available_port)
local PROXY_PORT=$(plugn trigger ports-get-available)
else
local PROXY_PORT=$(config_get --global DOKKU_PROXY_PORT)
PROXY_PORT=${PROXY_PORT:=80}
@@ -33,7 +33,7 @@ trigger-ports-proxy-configure-ports() {
PROXY_SSL_PORT=${PROXY_SSL_PORT:=443}
if [[ -z "$RAW_TCP_PORTS" ]] && [[ "$IS_APP_VHOST_ENABLED" == "false" ]]; then
dokku_log_info1 "No ssl port set, setting to random open high port"
PROXY_SSL_PORT=$(get_available_port)
PROXY_SSL_PORT=$(plugn trigger ports-get-available)
fi
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_PROXY_SSL_PORT="$PROXY_SSL_PORT"
fi