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-haproxy-vhosts-certs-force() {
return
fi
if [[ -n "$(fn-haproxy-letsencrypt-email)" ]]; then
if [[ -n "$(fn-haproxy-computed-letsencrypt-email)" ]]; then
echo true
fi
}

View File

@@ -71,11 +71,16 @@ cmd-haproxy-report-single() {
verify_app_name "$APP"
fi
local flag_map=(
"--haproxy-image: $(fn-haproxy-image)"
"--haproxy-letsencrypt-email: $(fn-haproxy-letsencrypt-email)"
"--haproxy-letsencrypt-server: $(fn-haproxy-letsencrypt-server)"
"--haproxy-log-level: $(fn-haproxy-log-level)"
"--haproxy-refresh-conf: $(fn-haproxy-refresh-conf)"
"--haproxy-computed-image: $(fn-haproxy-computed-image)"
"--haproxy-computed-letsencrypt-email: $(fn-haproxy-computed-letsencrypt-email)"
"--haproxy-computed-letsencrypt-server: $(fn-haproxy-computed-letsencrypt-server)"
"--haproxy-computed-log-level: $(fn-haproxy-computed-log-level)"
"--haproxy-computed-refresh-conf: $(fn-haproxy-computed-refresh-conf)"
"--haproxy-global-image: $(fn-haproxy-global-image)"
"--haproxy-global-letsencrypt-email: $(fn-haproxy-global-letsencrypt-email)"
"--haproxy-global-letsencrypt-server: $(fn-haproxy-global-letsencrypt-server)"
"--haproxy-global-log-level: $(fn-haproxy-global-log-level)"
"--haproxy-global-refresh-conf: $(fn-haproxy-global-refresh-conf)"
)
fn-report-validate-format "$FORMAT" "$INFO_FLAG"

View File

@@ -68,7 +68,7 @@ trigger-haproxy-vhosts-docker-args-process-deploy() {
fi
done < <(plugn trigger ports-get "$APP")
letsencrypt_email="$(fn-haproxy-letsencrypt-email)"
letsencrypt_email="$(fn-haproxy-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

@@ -35,33 +35,71 @@ fn-haproxy-template-compose-file() {
COMPOSE_TEMPLATE="$CUSTOM_COMPOSE_TEMPLATE"
fi
local SIGIL_PARAMS=(HAPROXY_IMAGE="$(fn-haproxy-image)"
HAPROXY_LOG_LEVEL="$(fn-haproxy-log-level)"
HAPROXY_LETSENCRYPT_EMAIL="$(fn-haproxy-letsencrypt-email)"
HAPROXY_LETSENCRYPT_SERVER="$(fn-haproxy-letsencrypt-server)"
HAPROXY_REFRESH_CONF="$(fn-haproxy-refresh-conf)")
local SIGIL_PARAMS=(HAPROXY_IMAGE="$(fn-haproxy-computed-image)"
HAPROXY_LOG_LEVEL="$(fn-haproxy-computed-log-level)"
HAPROXY_LETSENCRYPT_EMAIL="$(fn-haproxy-computed-letsencrypt-email)"
HAPROXY_LETSENCRYPT_SERVER="$(fn-haproxy-computed-letsencrypt-server)"
HAPROXY_REFRESH_CONF="$(fn-haproxy-computed-refresh-conf)")
sigil -f "$COMPOSE_TEMPLATE" "${SIGIL_PARAMS[@]}" | cat -s >"$OUTPUT_PATH"
}
fn-haproxy-image() {
fn-plugin-property-get-default "haproxy" "--global" "image" "$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/haproxy-vhosts/Dockerfile" | awk '{print $2}')"
fn-haproxy-global-image() {
fn-plugin-property-get-default "haproxy" "--global" "image" ""
}
fn-haproxy-log-level() {
local log_level
log_level="$(fn-plugin-property-get-default "haproxy" "--global" "log-level" "ERROR")"
echo "${log_level^^}"
fn-haproxy-computed-image() {
local value
value="$(fn-haproxy-global-image)"
if [[ -z "$value" ]]; then
value="$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/haproxy-vhosts/Dockerfile" | awk '{print $2}')"
fi
echo "$value"
}
fn-haproxy-letsencrypt-email() {
fn-haproxy-global-log-level() {
fn-plugin-property-get-default "haproxy" "--global" "log-level" ""
}
fn-haproxy-computed-log-level() {
local value
value="$(fn-haproxy-global-log-level)"
if [[ -z "$value" ]]; then
value="ERROR"
fi
echo "${value^^}"
}
fn-haproxy-global-letsencrypt-email() {
fn-plugin-property-get-default "haproxy" "--global" "letsencrypt-email" ""
}
fn-haproxy-letsencrypt-server() {
fn-plugin-property-get-default "haproxy" "--global" "letsencrypt-server" "https://acme-v02.api.letsencrypt.org/directory"
fn-haproxy-computed-letsencrypt-email() {
fn-haproxy-global-letsencrypt-email
}
fn-haproxy-refresh-conf() {
fn-plugin-property-get-default "haproxy" "--global" "refresh-conf" "10"
fn-haproxy-global-letsencrypt-server() {
fn-plugin-property-get-default "haproxy" "--global" "letsencrypt-server" ""
}
fn-haproxy-computed-letsencrypt-server() {
local value
value="$(fn-haproxy-global-letsencrypt-server)"
if [[ -z "$value" ]]; then
value="https://acme-v02.api.letsencrypt.org/directory"
fi
echo "$value"
}
fn-haproxy-global-refresh-conf() {
fn-plugin-property-get-default "haproxy" "--global" "refresh-conf" ""
}
fn-haproxy-computed-refresh-conf() {
local value
value="$(fn-haproxy-global-refresh-conf)"
if [[ -z "$value" ]]; then
value="10"
fi
echo "$value"
}