fix: split report global keys into raw and computed across plugins

The `<plugin>-global-<property>` keys in `:report` output returned the resolved value with the built-in default substituted in, so external tooling could not distinguish a property that had been set globally to the default from one that had never been set. The bare keys for caddy, haproxy, and traefik global-only properties had the same shape. The `global-<property>` keys now hold the raw stored value and are empty when nothing has been set, and a new `computed-<property>` key holds the effective value used at runtime, falling back through the per-app value (where one exists), the global value, and the built-in default. The bare global-only keys for the three proxy plugins are removed in favor of the raw/computed pair. Closes #8631.
This commit is contained in:
Jose Diaz-Gonzalez
2026-05-13 16:39:38 -04:00
parent f3bdd7e4ec
commit 76b033234f
56 changed files with 1031 additions and 334 deletions

View File

@@ -13,7 +13,7 @@ trigger-caddy-vhosts-certs-force() {
return
fi
if [[ -n "$(fn-caddy-letsencrypt-email)" ]]; then
if [[ -n "$(fn-caddy-computed-letsencrypt-email)" ]]; then
echo true
fi
}

View File

@@ -70,23 +70,34 @@ cmd-caddy-report-single() {
local flag_map=()
if [[ "$APP" == "--global" ]]; then
flag_map=(
"--caddy-computed-image: $(fn-caddy-computed-image)"
"--caddy-computed-letsencrypt-email: $(fn-caddy-computed-letsencrypt-email)"
"--caddy-computed-letsencrypt-server: $(fn-caddy-computed-letsencrypt-server)"
"--caddy-computed-log-level: $(fn-caddy-computed-log-level)"
"--caddy-computed-polling-interval: $(fn-caddy-computed-polling-interval)"
"--caddy-computed-tls-internal: $(fn-caddy-computed-tls-internal "$APP")"
"--caddy-global-image: $(fn-caddy-global-image)"
"--caddy-global-letsencrypt-email: $(fn-caddy-global-letsencrypt-email)"
"--caddy-global-letsencrypt-server: $(fn-caddy-global-letsencrypt-server)"
"--caddy-global-log-level: $(fn-caddy-global-log-level)"
"--caddy-global-polling-interval: $(fn-caddy-global-polling-interval)"
"--caddy-global-tls-internal: $(fn-caddy-global-tls-internal)"
"--caddy-image: $(fn-caddy-image)"
"--caddy-letsencrypt-email: $(fn-caddy-letsencrypt-email)"
"--caddy-letsencrypt-server: $(fn-caddy-letsencrypt-server)"
"--caddy-log-level: $(fn-caddy-log-level)"
"--caddy-polling-interval: $(fn-caddy-polling-interval)"
)
else
verify_app_name "$APP"
flag_map=(
"--caddy-computed-image: $(fn-caddy-computed-image)"
"--caddy-computed-letsencrypt-email: $(fn-caddy-computed-letsencrypt-email)"
"--caddy-computed-letsencrypt-server: $(fn-caddy-computed-letsencrypt-server)"
"--caddy-computed-log-level: $(fn-caddy-computed-log-level)"
"--caddy-computed-polling-interval: $(fn-caddy-computed-polling-interval)"
"--caddy-computed-tls-internal: $(fn-caddy-computed-tls-internal "$APP")"
"--caddy-global-image: $(fn-caddy-global-image)"
"--caddy-global-letsencrypt-email: $(fn-caddy-global-letsencrypt-email)"
"--caddy-global-letsencrypt-server: $(fn-caddy-global-letsencrypt-server)"
"--caddy-global-log-level: $(fn-caddy-global-log-level)"
"--caddy-global-polling-interval: $(fn-caddy-global-polling-interval)"
"--caddy-global-tls-internal: $(fn-caddy-global-tls-internal)"
"--caddy-image: $(fn-caddy-image)"
"--caddy-letsencrypt-email: $(fn-caddy-letsencrypt-email)"
"--caddy-letsencrypt-server: $(fn-caddy-letsencrypt-server)"
"--caddy-log-level: $(fn-caddy-log-level)"
"--caddy-polling-interval: $(fn-caddy-polling-interval)"
"--caddy-tls-internal: $(fn-caddy-tls-internal "$APP")"
)
fi

View File

@@ -68,7 +68,7 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
fi
done < <(plugn trigger ports-get "$APP")
letsencrypt_email="$(fn-caddy-letsencrypt-email)"
letsencrypt_email="$(fn-caddy-computed-letsencrypt-email)"
if [[ -n "$letsencrypt_email" ]] && [[ -z "$proxy_container_https_port" ]]; then
proxy_container_https_port_candidate="$proxy_container_http_port_candidate"
proxy_host_https_port_candidate="$proxy_host_http_port_candidate"

View File

@@ -36,35 +36,73 @@ fn-caddy-template-compose-file() {
fi
local SIGIL_PARAMS=(CADDY_DATA_DIR="${DOKKU_LIB_ROOT}/data/caddy"
CADDY_IMAGE="$(fn-caddy-image)"
CADDY_LETSENCRYPT_EMAIL="$(fn-caddy-letsencrypt-email)"
CADDY_LETSENCRYPT_SERVER="$(fn-caddy-letsencrypt-server)"
CADDY_LOG_LEVEL="$(fn-caddy-log-level)"
CADDY_POLLING_INTERVAL="$(fn-caddy-polling-interval)")
CADDY_IMAGE="$(fn-caddy-computed-image)"
CADDY_LETSENCRYPT_EMAIL="$(fn-caddy-computed-letsencrypt-email)"
CADDY_LETSENCRYPT_SERVER="$(fn-caddy-computed-letsencrypt-server)"
CADDY_LOG_LEVEL="$(fn-caddy-computed-log-level)"
CADDY_POLLING_INTERVAL="$(fn-caddy-computed-polling-interval)")
sigil -f "$COMPOSE_TEMPLATE" "${SIGIL_PARAMS[@]}" | cat -s >"$OUTPUT_PATH"
}
fn-caddy-image() {
fn-plugin-property-get-default "caddy" "--global" "image" "$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/caddy-vhosts/Dockerfile" | awk '{print $2}')"
fn-caddy-global-image() {
fn-plugin-property-get-default "caddy" "--global" "image" ""
}
fn-caddy-letsencrypt-email() {
fn-caddy-computed-image() {
local value
value="$(fn-caddy-global-image)"
if [[ -z "$value" ]]; then
value="$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/caddy-vhosts/Dockerfile" | awk '{print $2}')"
fi
echo "$value"
}
fn-caddy-global-letsencrypt-email() {
fn-plugin-property-get-default "caddy" "--global" "letsencrypt-email" ""
}
fn-caddy-letsencrypt-server() {
fn-plugin-property-get-default "caddy" "--global" "letsencrypt-server" "https://acme-v02.api.letsencrypt.org/directory"
fn-caddy-computed-letsencrypt-email() {
fn-caddy-global-letsencrypt-email
}
fn-caddy-log-level() {
local log_level
log_level="$(fn-plugin-property-get-default "caddy" "--global" "log-level" "ERROR")"
echo "${log_level^^}"
fn-caddy-global-letsencrypt-server() {
fn-plugin-property-get-default "caddy" "--global" "letsencrypt-server" ""
}
fn-caddy-polling-interval() {
fn-plugin-property-get-default "caddy" "--global" "polling-interval" "5s"
fn-caddy-computed-letsencrypt-server() {
local value
value="$(fn-caddy-global-letsencrypt-server)"
if [[ -z "$value" ]]; then
value="https://acme-v02.api.letsencrypt.org/directory"
fi
echo "$value"
}
fn-caddy-global-log-level() {
fn-plugin-property-get-default "caddy" "--global" "log-level" ""
}
fn-caddy-computed-log-level() {
local value
value="$(fn-caddy-global-log-level)"
if [[ -z "$value" ]]; then
value="ERROR"
fi
echo "${value^^}"
}
fn-caddy-global-polling-interval() {
fn-plugin-property-get-default "caddy" "--global" "polling-interval" ""
}
fn-caddy-computed-polling-interval() {
local value
value="$(fn-caddy-global-polling-interval)"
if [[ -z "$value" ]]; then
value="5s"
fi
echo "$value"
}
fn-caddy-tls-internal() {
@@ -79,9 +117,12 @@ fn-caddy-computed-tls-internal() {
if [[ -z "$value" ]]; then
value="$(fn-caddy-global-tls-internal)"
fi
if [[ -z "$value" ]]; then
value="false"
fi
echo "$value"
}
fn-caddy-global-tls-internal() {
fn-plugin-property-get-default "caddy" "--global" "tls-internal" "false"
fn-plugin-property-get-default "caddy" "--global" "tls-internal" ""
}