fix: split openresty report keys into global and computed pairs
The `openresty:report --format json` payload emitted bare property names for the four global-only properties (`image`, `letsencrypt-email`, `letsencrypt-server`, `allowed-letsencrypt-domains-func-base64`), while `hsts` already used the `global-`/`computed-` convention adopted by the other proxy plugins. External tooling consuming the report had to maintain a per-property naming map within a single plugin. The global flag map now emits `--openresty-global-<X>` (raw stored value, empty when unset) and `--openresty-computed-<X>` (effective value with the built-in default applied) for those four properties plus `hsts`, and the per-app map gains the same pair for the global-only properties. The compose template and the two non-report callers consume the `computed-` accessors so the runtime behavior is unchanged.
This commit is contained in:
@@ -13,7 +13,7 @@ trigger-openresty-vhosts-certs-force() {
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -n "$(fn-openresty-letsencrypt-email)" ]]; then
|
||||
if [[ -n "$(fn-openresty-computed-letsencrypt-email)" ]]; then
|
||||
echo true
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -70,34 +70,43 @@ cmd-openresty-report-single() {
|
||||
local flag_map=()
|
||||
if [[ "$APP" == "--global" ]]; then
|
||||
flag_map=(
|
||||
"--openresty-allowed-letsencrypt-domains-func-base64: $(fn-openresty-allowed-letsencrypt-domains-func-base64)"
|
||||
"--openresty-global-hsts: $(fn-plugin-property-get-default "openresty" "--global" "hsts" "true")"
|
||||
"--openresty-image: $(fn-openresty-image)"
|
||||
"--openresty-letsencrypt-email: $(fn-openresty-letsencrypt-email)"
|
||||
"--openresty-letsencrypt-server: $(fn-openresty-letsencrypt-server)"
|
||||
"--openresty-global-allowed-letsencrypt-domains-func-base64: $(fn-openresty-global-allowed-letsencrypt-domains-func-base64)"
|
||||
"--openresty-computed-allowed-letsencrypt-domains-func-base64: $(fn-openresty-computed-allowed-letsencrypt-domains-func-base64)"
|
||||
"--openresty-global-hsts: $(fn-plugin-property-get-default "openresty" "--global" "hsts" "")"
|
||||
"--openresty-computed-hsts: $(fn-openresty-hsts-is-enabled "--global")"
|
||||
"--openresty-global-image: $(fn-openresty-global-image)"
|
||||
"--openresty-computed-image: $(fn-openresty-computed-image)"
|
||||
"--openresty-global-letsencrypt-email: $(fn-openresty-global-letsencrypt-email)"
|
||||
"--openresty-computed-letsencrypt-email: $(fn-openresty-computed-letsencrypt-email)"
|
||||
"--openresty-global-letsencrypt-server: $(fn-openresty-global-letsencrypt-server)"
|
||||
"--openresty-computed-letsencrypt-server: $(fn-openresty-computed-letsencrypt-server)"
|
||||
)
|
||||
else
|
||||
verify_app_name "$APP"
|
||||
flag_map=(
|
||||
"--openresty-access-log-format: $(fn-openresty-access-log-format "$APP")"
|
||||
"--openresty-access-log-path: $(fn-openresty-access-log-path "$APP")"
|
||||
"--openresty-allowed-letsencrypt-domains-func-base64: $(fn-openresty-allowed-letsencrypt-domains-func-base64)"
|
||||
"--openresty-global-allowed-letsencrypt-domains-func-base64: $(fn-openresty-global-allowed-letsencrypt-domains-func-base64)"
|
||||
"--openresty-computed-allowed-letsencrypt-domains-func-base64: $(fn-openresty-computed-allowed-letsencrypt-domains-func-base64)"
|
||||
"--openresty-bind-address-ipv4: $(fn-openresty-bind-address-ipv4 "$APP")"
|
||||
"--openresty-bind-address-ipv6: $(fn-openresty-bind-address-ipv6 "$APP")"
|
||||
"--openresty-client-body-timeout: $(fn-openresty-client-body-timeout "$APP")"
|
||||
"--openresty-client-header-timeout: $(fn-openresty-client-header-timeout "$APP")"
|
||||
"--openresty-client-max-body-size: $(fn-openresty-client-max-body-size "$APP")"
|
||||
"--openresty-error-log-path: $(fn-openresty-error-log-path "$APP")"
|
||||
"--openresty-global-hsts: $(fn-plugin-property-get-default "openresty" "--global" "hsts" "true")"
|
||||
"--openresty-global-hsts: $(fn-plugin-property-get-default "openresty" "--global" "hsts" "")"
|
||||
"--openresty-computed-hsts: $(fn-openresty-hsts-is-enabled "$APP")"
|
||||
"--openresty-hsts: $(fn-plugin-property-get-default "openresty" "$APP" "hsts" "")"
|
||||
"--openresty-hsts-include-subdomains: $(fn-openresty-hsts-include-subdomains "$APP")"
|
||||
"--openresty-hsts-max-age: $(fn-openresty-hsts-max-age "$APP")"
|
||||
"--openresty-hsts-preload: $(fn-openresty-hsts-preload "$APP")"
|
||||
"--openresty-image: $(fn-openresty-image)"
|
||||
"--openresty-global-image: $(fn-openresty-global-image)"
|
||||
"--openresty-computed-image: $(fn-openresty-computed-image)"
|
||||
"--openresty-keepalive-timeout: $(fn-openresty-keepalive-timeout "$APP")"
|
||||
"--openresty-letsencrypt-email: $(fn-openresty-letsencrypt-email)"
|
||||
"--openresty-letsencrypt-server: $(fn-openresty-letsencrypt-server)"
|
||||
"--openresty-global-letsencrypt-email: $(fn-openresty-global-letsencrypt-email)"
|
||||
"--openresty-computed-letsencrypt-email: $(fn-openresty-computed-letsencrypt-email)"
|
||||
"--openresty-global-letsencrypt-server: $(fn-openresty-global-letsencrypt-server)"
|
||||
"--openresty-computed-letsencrypt-server: $(fn-openresty-computed-letsencrypt-server)"
|
||||
"--openresty-lingering-timeout: $(fn-openresty-lingering-timeout "$APP")"
|
||||
"--openresty-proxy-buffer-size: $(fn-openresty-proxy-buffer-size "$APP")"
|
||||
"--openresty-proxy-buffering: $(fn-openresty-proxy-buffering "$APP")"
|
||||
|
||||
@@ -133,7 +133,7 @@ trigger-openresty-vhosts-docker-args-process-deploy() {
|
||||
fi
|
||||
|
||||
letsencrypt_value="false"
|
||||
if [[ -n "$(fn-openresty-letsencrypt-email)" ]]; then
|
||||
if [[ -n "$(fn-openresty-computed-letsencrypt-email)" ]]; then
|
||||
if [[ -n "$proxy_container_https_port" ]] || [[ -n "$proxy_container_https_port_candidate" ]]; then
|
||||
letsencrypt_value="true"
|
||||
fi
|
||||
|
||||
@@ -26,8 +26,14 @@ fn-openresty-access-log-path() {
|
||||
fn-plugin-property-get-default "openresty" "$APP" "access-log-path" "${OPENRESTY_LOG_ROOT}/${APP}-access.log"
|
||||
}
|
||||
|
||||
fn-openresty-allowed-letsencrypt-domains-func-base64() {
|
||||
declare desc="get the configured allowed domains func base64"
|
||||
fn-openresty-global-allowed-letsencrypt-domains-func-base64() {
|
||||
declare desc="get the raw configured allowed domains func base64"
|
||||
|
||||
fn-plugin-property-get-default "openresty" "--global" "allowed-letsencrypt-domains-func-base64" ""
|
||||
}
|
||||
|
||||
fn-openresty-computed-allowed-letsencrypt-domains-func-base64() {
|
||||
declare desc="get the effective allowed domains func base64, falling back to the default stub"
|
||||
|
||||
fn-plugin-property-get-default "openresty" "--global" "allowed-letsencrypt-domains-func-base64" "return true" | base64 -w 0
|
||||
}
|
||||
@@ -131,8 +137,21 @@ fn-openresty-hsts-is-enabled() {
|
||||
echo "$hsts_is_enabled"
|
||||
}
|
||||
|
||||
fn-openresty-image() {
|
||||
fn-plugin-property-get-default "openresty" "--global" "image" "$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/openresty-vhosts/Dockerfile" | awk '{print $2}')"
|
||||
fn-openresty-global-image() {
|
||||
declare desc="get the raw configured image"
|
||||
|
||||
fn-plugin-property-get-default "openresty" "--global" "image" ""
|
||||
}
|
||||
|
||||
fn-openresty-computed-image() {
|
||||
declare desc="get the effective image, falling back to the Dockerfile FROM line"
|
||||
local value
|
||||
|
||||
value="$(fn-openresty-global-image)"
|
||||
if [[ -z "$value" ]]; then
|
||||
value="$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/openresty-vhosts/Dockerfile" | awk '{print $2}')"
|
||||
fi
|
||||
echo "$value"
|
||||
}
|
||||
|
||||
fn-openresty-keepalive-timeout() {
|
||||
@@ -142,12 +161,33 @@ fn-openresty-keepalive-timeout() {
|
||||
fn-plugin-property-get-default "openresty" "$APP" "keepalive-timeout" "75s"
|
||||
}
|
||||
|
||||
fn-openresty-letsencrypt-email() {
|
||||
fn-openresty-global-letsencrypt-email() {
|
||||
declare desc="get the raw configured letsencrypt email"
|
||||
|
||||
fn-plugin-property-get-default "openresty" "--global" "letsencrypt-email" ""
|
||||
}
|
||||
|
||||
fn-openresty-letsencrypt-server() {
|
||||
fn-plugin-property-get-default "openresty" "--global" "letsencrypt-server" "https://acme-v02.api.letsencrypt.org/directory"
|
||||
fn-openresty-computed-letsencrypt-email() {
|
||||
declare desc="get the effective letsencrypt email"
|
||||
|
||||
fn-openresty-global-letsencrypt-email
|
||||
}
|
||||
|
||||
fn-openresty-global-letsencrypt-server() {
|
||||
declare desc="get the raw configured letsencrypt server"
|
||||
|
||||
fn-plugin-property-get-default "openresty" "--global" "letsencrypt-server" ""
|
||||
}
|
||||
|
||||
fn-openresty-computed-letsencrypt-server() {
|
||||
declare desc="get the effective letsencrypt server, falling back to the production directory"
|
||||
local value
|
||||
|
||||
value="$(fn-openresty-global-letsencrypt-server)"
|
||||
if [[ -z "$value" ]]; then
|
||||
value="https://acme-v02.api.letsencrypt.org/directory"
|
||||
fi
|
||||
echo "$value"
|
||||
}
|
||||
|
||||
fn-openresty-log-root() {
|
||||
@@ -251,11 +291,11 @@ fn-openresty-template-compose-file() {
|
||||
fi
|
||||
|
||||
local SIGIL_PARAMS=(OPENRESTY_DATA_DIR="${DOKKU_LIB_ROOT}/data/openresty-vhosts/.docker-letsencrypt"
|
||||
OPENRESTY_IMAGE="$(fn-openresty-image)"
|
||||
OPENRESTY_LETSENCRYPT_EMAIL="$(fn-openresty-letsencrypt-email)"
|
||||
OPENRESTY_LETSENCRYPT_SERVER="$(fn-openresty-letsencrypt-server)")
|
||||
OPENRESTY_IMAGE="$(fn-openresty-computed-image)"
|
||||
OPENRESTY_LETSENCRYPT_EMAIL="$(fn-openresty-computed-letsencrypt-email)"
|
||||
OPENRESTY_LETSENCRYPT_SERVER="$(fn-openresty-computed-letsencrypt-server)")
|
||||
|
||||
local ALLOWED_DOMAINS_FUNC_BASE64="$(fn-openresty-allowed-letsencrypt-domains-func-base64)"
|
||||
local ALLOWED_DOMAINS_FUNC_BASE64="$(fn-openresty-computed-allowed-letsencrypt-domains-func-base64)"
|
||||
if [[ -n "$ALLOWED_DOMAINS_FUNC_BASE64" ]]; then
|
||||
SIGIL_PARAMS+=(ALLOWED_DOMAINS_FUNC_BASE64="$ALLOWED_DOMAINS_FUNC_BASE64")
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user