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.
129 lines
3.4 KiB
Bash
Executable File
129 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
|
set -eo pipefail
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
|
|
fn-caddy-logs() {
|
|
declare desc="shows the logs for the caddy container"
|
|
declare TAIL="$1" NUM="$2"
|
|
local dokku_logs_args=("--tail" "$NUM")
|
|
|
|
if [[ "$TAIL" == "true" ]]; then
|
|
dokku_logs_args+=("--follow")
|
|
fi
|
|
|
|
"$DOCKER_BIN" logs caddy-caddy-1 "${dokku_logs_args[@]}"
|
|
}
|
|
|
|
fn-caddy-logs-usage() {
|
|
declare desc="logs specific usage"
|
|
echo "Usage: dokku caddy:logs"
|
|
echo " display recent caddy log output"
|
|
echo ""
|
|
echo " -n, --num NUM # the number of lines to display"
|
|
echo " -t, --tail # continually stream logs"
|
|
}
|
|
|
|
fn-caddy-template-compose-file() {
|
|
declare desc="templates out the compose file"
|
|
declare OUTPUT_PATH="$1"
|
|
local COMPOSE_TEMPLATE="$PLUGIN_AVAILABLE_PATH/caddy-vhosts/templates/compose.yml.sigil"
|
|
|
|
CUSTOM_COMPOSE_TEMPLATE="$(plugn trigger caddy-template-source "$APP")"
|
|
if [[ -n "$CUSTOM_COMPOSE_TEMPLATE" ]]; then
|
|
COMPOSE_TEMPLATE="$CUSTOM_COMPOSE_TEMPLATE"
|
|
fi
|
|
|
|
local SIGIL_PARAMS=(CADDY_DATA_DIR="${DOKKU_LIB_ROOT}/data/caddy"
|
|
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-global-image() {
|
|
fn-plugin-property-get-default "caddy" "--global" "image" ""
|
|
}
|
|
|
|
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-computed-letsencrypt-email() {
|
|
fn-caddy-global-letsencrypt-email
|
|
}
|
|
|
|
fn-caddy-global-letsencrypt-server() {
|
|
fn-plugin-property-get-default "caddy" "--global" "letsencrypt-server" ""
|
|
}
|
|
|
|
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() {
|
|
declare APP="$1"
|
|
fn-plugin-property-get-default "caddy" "$APP" "tls-internal" ""
|
|
}
|
|
|
|
fn-caddy-computed-tls-internal() {
|
|
declare APP="$1"
|
|
local value
|
|
value="$(fn-caddy-tls-internal "$APP")"
|
|
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" ""
|
|
}
|