refactor: use ports-get plugn trigger for fetching port mappings

This removes use of ports internals from other plugins, which will make it easier to refactor the underlying property storage.
This commit is contained in:
Jose Diaz-Gonzalez
2023-07-08 15:23:29 -04:00
parent 9bd6e17903
commit 914475f3e4
10 changed files with 48 additions and 24 deletions

View File

@@ -321,10 +321,10 @@ nginx_build_config() {
plugn trigger proxy-configure-ports "$APP"
local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
local PROXY_PORT_MAP=$(config_get "$APP" DOKKU_PROXY_PORT_MAP)
local PROXY_PORT_MAP=$(plugn trigger ports-get "$APP")
local PORT_MAP proxy_port_map
for PORT_MAP in $PROXY_PORT_MAP; do
local PORT_MAP PROXY_PORT_MAP proxy_port_map
while read -r PORT_MAP; do
local PROXY_UPSTREAM_SCHEME="$(awk -F ':' '{ print $1 }' <<<"$PORT_MAP")"
if [[ "$PROXY_UPSTREAM_SCHEME" == "https" ]] && [[ "$IS_SSL_ENABLED" == "false" ]]; then
dokku_log_warn "Ignoring detected https port mapping without an accompanying ssl certificate (${PORT_MAP})"
@@ -337,8 +337,8 @@ nginx_build_config() {
if [[ "$(is_val_in_list "$PROXY_UPSTREAM_PORT" "$PROXY_UPSTREAM_PORTS" " ")" == "false" ]]; then
local PROXY_UPSTREAM_PORTS+="$PROXY_UPSTREAM_PORT "
fi
done
PROXY_PORT_MAP="$proxy_port_map"
done < <(plugn trigger ports-get "$APP")
PROXY_PORT_MAP="$(echo "$proxy_port_map" | xargs)" # trailing spaces mess up default template
local PROXY_UPSTREAM_PORTS="$(echo "$PROXY_UPSTREAM_PORTS" | xargs)"
local SSL_INUSE=
@@ -379,8 +379,6 @@ nginx_build_config() {
HTTP2_PUSH_SUPPORTED="$(is_http2_push_enabled "$NGINX_VERSION")"
GRPC_SUPPORTED="$(is_grpc_enabled "$NGINX_VERSION")"
PROXY_PORT_MAP=$(echo "$PROXY_PORT_MAP" | xargs) # trailing spaces mess up default template
local NGINX_LOG_ROOT="$(fn-nginx-log-root)"
local NGINX_ACCESS_LOG_FORMAT="$(fn-nginx-access-log-format "$APP")"
local NGINX_ACCESS_LOG_PATH="$(fn-nginx-access-log-path "$APP")"