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

@@ -8,7 +8,7 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
declare desc="nginx-vhosts core-post-deploy plugin trigger"
declare trigger="docker-args-process-deploy"
declare APP="$1" IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3" PROC_TYPE="$4" CONTAINER_INDEX="$5"
local app_domains caddy_domains is_app_listening letsencrypt_email output proxy_container_port proxy_host_port port_map proxy_port_map proxy_scheme proxy_schemes scheme tls_internal
local app_domains caddy_domains is_app_listening letsencrypt_email output proxy_container_port proxy_host_port port_map proxy_scheme proxy_schemes scheme tls_internal
local proxy_container_http_port proxy_container_http_port_candidate proxy_host_http_port_candidate
local proxy_container_https_port proxy_container_https_port_candidate proxy_host_https_port_candidate
local STDIN=$(cat)
@@ -37,8 +37,7 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
# so this block parses the port mappings and tries to find the correct
# mapping to expose
is_app_listening="false"
proxy_port_map="$(plugn trigger config-get "$APP" DOKKU_PROXY_PORT_MAP)"
for port_map in $proxy_port_map; do
while read -r port_map; do
proxy_scheme="$(awk -F ':' '{ print $1 }' <<<"$port_map")"
proxy_host_port="$(awk -F ':' '{ print $2 }' <<<"$port_map")"
proxy_container_port="$(awk -F ':' '{ print $3 }' <<<"$port_map")"
@@ -66,7 +65,7 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
proxy_container_https_port="$proxy_container_port"
fi
fi
done
done < <(plugn trigger ports-get "$APP")
letsencrypt_email="$(fn-caddy-letsencrypt-email)"
if [[ -n "$letsencrypt_email" ]] && [[ -z "$proxy_container_https_port" ]]; then