mirror of
https://github.com/dokku/dokku.git
synced 2026-08-29 10:08:53 +02:00
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.
246 lines
6.8 KiB
Bash
Executable File
246 lines
6.8 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-traefik-logs() {
|
|
declare desc="shows the logs for the traefik container"
|
|
declare TAIL="$1" NUM="$2"
|
|
local dokku_logs_args=("--tail" "$NUM")
|
|
|
|
if [[ "$TAIL" == "true" ]]; then
|
|
dokku_logs_args+=("--follow")
|
|
fi
|
|
|
|
"$DOCKER_BIN" logs traefik-traefik-1 "${dokku_logs_args[@]}"
|
|
}
|
|
|
|
fn-traefik-logs-usage() {
|
|
declare desc="logs specific usage"
|
|
echo "Usage: dokku traefik:logs"
|
|
echo " display recent traefik log output"
|
|
echo ""
|
|
echo " -n, --num NUM # the number of lines to display"
|
|
echo " -t, --tail # continually stream logs"
|
|
}
|
|
|
|
fn-traefik-template-compose-file() {
|
|
declare desc="templates out the compose file"
|
|
declare OUTPUT_PATH="$1"
|
|
local COMPOSE_TEMPLATE="$PLUGIN_AVAILABLE_PATH/traefik-vhosts/templates/compose.yml.sigil"
|
|
local basic_auth basic_auth_password basic_auth_username
|
|
|
|
CUSTOM_COMPOSE_TEMPLATE="$(plugn trigger traefik-template-source "$APP")"
|
|
if [[ -n "$CUSTOM_COMPOSE_TEMPLATE" ]]; then
|
|
COMPOSE_TEMPLATE="$CUSTOM_COMPOSE_TEMPLATE"
|
|
fi
|
|
|
|
basic_auth_password="$(fn-traefik-computed-basic-auth-password)"
|
|
basic_auth_username="$(fn-traefik-computed-basic-auth-username)"
|
|
if [[ -n "$basic_auth_password" ]] && [[ -n "$basic_auth_username" ]]; then
|
|
basic_auth="$(htpasswd -nb "$basic_auth_username" "$basic_auth_password" | sed -e s/\\$/\\$\\$/g)"
|
|
fi
|
|
|
|
local dns_provider_env_vars=""
|
|
local dns_provider
|
|
dns_provider="$(fn-traefik-computed-dns-provider)"
|
|
if [[ -n "$dns_provider" ]]; then
|
|
dns_provider_env_vars="$(fn-traefik-dns-provider-env-vars)"
|
|
fi
|
|
|
|
local api_entry_point_address api_entry_point_port=""
|
|
api_entry_point_address="$(fn-traefik-computed-api-entry-point-address)"
|
|
if [[ -n "$api_entry_point_address" ]]; then
|
|
api_entry_point_port="${api_entry_point_address##*:}"
|
|
fi
|
|
|
|
local SIGIL_PARAMS=(TRAEFIK_API_ENABLED="$(fn-traefik-computed-api-enabled)"
|
|
TRAEFIK_API_ENTRY_POINT="$(fn-traefik-computed-api-entry-point)"
|
|
TRAEFIK_API_ENTRY_POINT_ADDRESS="$api_entry_point_address"
|
|
TRAEFIK_API_ENTRY_POINT_PORT="$api_entry_point_port"
|
|
TRAEFIK_API_VHOST="$(fn-traefik-computed-api-vhost)"
|
|
TRAEFIK_BASIC_AUTH="$basic_auth"
|
|
TRAEFIK_CHALLENGE_MODE="$(fn-traefik-computed-challenge-mode)"
|
|
TRAEFIK_DASHBOARD_ENABLED="$(fn-traefik-computed-dashboard-enabled)"
|
|
TRAEFIK_DATA_DIR="${DOKKU_LIB_ROOT}/data/traefik"
|
|
TRAEFIK_DNS_PROVIDER="$dns_provider"
|
|
TRAEFIK_DNS_PROVIDER_ENV_VARS="$dns_provider_env_vars"
|
|
TRAEFIK_IMAGE="$(fn-traefik-computed-image)"
|
|
TRAEFIK_LETSENCRYPT_EMAIL="$(fn-traefik-computed-letsencrypt-email)"
|
|
TRAEFIK_LETSENCRYPT_SERVER="$(fn-traefik-computed-letsencrypt-server)"
|
|
TRAEFIK_LOG_LEVEL="$(fn-traefik-computed-log-level)")
|
|
|
|
sigil -f "$COMPOSE_TEMPLATE" "${SIGIL_PARAMS[@]}" | cat -s >"$OUTPUT_PATH"
|
|
}
|
|
|
|
fn-traefik-global-api-enabled() {
|
|
fn-plugin-property-get-default "traefik" "--global" "api-enabled" ""
|
|
}
|
|
|
|
fn-traefik-computed-api-enabled() {
|
|
local value
|
|
value="$(fn-traefik-global-api-enabled)"
|
|
if [[ -z "$value" ]]; then
|
|
value="false"
|
|
fi
|
|
echo "$value"
|
|
}
|
|
|
|
fn-traefik-global-api-vhost() {
|
|
fn-plugin-property-get-default "traefik" "--global" "api-vhost" ""
|
|
}
|
|
|
|
fn-traefik-computed-api-vhost() {
|
|
local value
|
|
value="$(fn-traefik-global-api-vhost)"
|
|
if [[ -z "$value" ]]; then
|
|
value="traefik.dokku.me"
|
|
fi
|
|
echo "$value"
|
|
}
|
|
|
|
fn-traefik-global-basic-auth-password() {
|
|
fn-plugin-property-get-default "traefik" "--global" "basic-auth-password" ""
|
|
}
|
|
|
|
fn-traefik-computed-basic-auth-password() {
|
|
fn-traefik-global-basic-auth-password
|
|
}
|
|
|
|
fn-traefik-global-basic-auth-username() {
|
|
fn-plugin-property-get-default "traefik" "--global" "basic-auth-username" ""
|
|
}
|
|
|
|
fn-traefik-computed-basic-auth-username() {
|
|
fn-traefik-global-basic-auth-username
|
|
}
|
|
|
|
fn-traefik-global-dashboard-enabled() {
|
|
fn-plugin-property-get-default "traefik" "--global" "dashboard-enabled" ""
|
|
}
|
|
|
|
fn-traefik-computed-dashboard-enabled() {
|
|
local value
|
|
value="$(fn-traefik-global-dashboard-enabled)"
|
|
if [[ -z "$value" ]]; then
|
|
value="false"
|
|
fi
|
|
echo "$value"
|
|
}
|
|
|
|
fn-traefik-global-image() {
|
|
fn-plugin-property-get-default "traefik" "--global" "image" ""
|
|
}
|
|
|
|
fn-traefik-computed-image() {
|
|
local value
|
|
value="$(fn-traefik-global-image)"
|
|
if [[ -z "$value" ]]; then
|
|
value="$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/traefik-vhosts/Dockerfile" | awk '{print $2}')"
|
|
fi
|
|
echo "$value"
|
|
}
|
|
|
|
fn-traefik-global-letsencrypt-email() {
|
|
fn-plugin-property-get-default "traefik" "--global" "letsencrypt-email" ""
|
|
}
|
|
|
|
fn-traefik-computed-letsencrypt-email() {
|
|
fn-traefik-global-letsencrypt-email
|
|
}
|
|
|
|
fn-traefik-global-letsencrypt-server() {
|
|
fn-plugin-property-get-default "traefik" "--global" "letsencrypt-server" ""
|
|
}
|
|
|
|
fn-traefik-computed-letsencrypt-server() {
|
|
local value
|
|
value="$(fn-traefik-global-letsencrypt-server)"
|
|
if [[ -z "$value" ]]; then
|
|
value="https://acme-v02.api.letsencrypt.org/directory"
|
|
fi
|
|
echo "$value"
|
|
}
|
|
|
|
fn-traefik-global-log-level() {
|
|
fn-plugin-property-get-default "traefik" "--global" "log-level" ""
|
|
}
|
|
|
|
fn-traefik-computed-log-level() {
|
|
local value
|
|
value="$(fn-traefik-global-log-level)"
|
|
if [[ -z "$value" ]]; then
|
|
value="ERROR"
|
|
fi
|
|
echo "${value^^}"
|
|
}
|
|
|
|
fn-traefik-global-http-entry-point() {
|
|
fn-plugin-property-get-default "traefik" "--global" "http-entry-point" ""
|
|
}
|
|
|
|
fn-traefik-computed-http-entry-point() {
|
|
local value
|
|
value="$(fn-traefik-global-http-entry-point)"
|
|
if [[ -z "$value" ]]; then
|
|
value="http"
|
|
fi
|
|
echo "$value"
|
|
}
|
|
|
|
fn-traefik-global-https-entry-point() {
|
|
fn-plugin-property-get-default "traefik" "--global" "https-entry-point" ""
|
|
}
|
|
|
|
fn-traefik-computed-https-entry-point() {
|
|
local value
|
|
value="$(fn-traefik-global-https-entry-point)"
|
|
if [[ -z "$value" ]]; then
|
|
value="https"
|
|
fi
|
|
echo "$value"
|
|
}
|
|
|
|
fn-traefik-global-api-entry-point() {
|
|
fn-plugin-property-get-default "traefik" "--global" "api-entry-point" ""
|
|
}
|
|
|
|
fn-traefik-computed-api-entry-point() {
|
|
fn-traefik-global-api-entry-point
|
|
}
|
|
|
|
fn-traefik-global-api-entry-point-address() {
|
|
fn-plugin-property-get-default "traefik" "--global" "api-entry-point-address" ""
|
|
}
|
|
|
|
fn-traefik-computed-api-entry-point-address() {
|
|
fn-traefik-global-api-entry-point-address
|
|
}
|
|
|
|
fn-traefik-global-challenge-mode() {
|
|
fn-plugin-property-get-default "traefik" "--global" "challenge-mode" ""
|
|
}
|
|
|
|
fn-traefik-computed-challenge-mode() {
|
|
local value
|
|
value="$(fn-traefik-global-challenge-mode)"
|
|
if [[ -z "$value" ]]; then
|
|
value="tls"
|
|
fi
|
|
echo "$value"
|
|
}
|
|
|
|
fn-traefik-global-dns-provider() {
|
|
fn-plugin-property-get-default "traefik" "--global" "dns-provider" ""
|
|
}
|
|
|
|
fn-traefik-computed-dns-provider() {
|
|
fn-traefik-global-dns-provider
|
|
}
|
|
|
|
fn-traefik-dns-provider-env-vars() {
|
|
declare desc="returns all dns-provider-* environment variables"
|
|
fn-plugin-property-get-all-by-prefix "traefik" "--global" "dns-provider-"
|
|
}
|