refactor: move domain manipulation into triggers
This allows other plugins to avoid understanding the underlying details of how domains might be integrated with.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
|
||||
|
||||
trigger-nginx-vhosts-core-post-deploy() {
|
||||
@@ -17,12 +16,7 @@ trigger-nginx-vhosts-core-post-deploy() {
|
||||
|
||||
HAS_NETWORK_CONFIG="$(plugn trigger network-config-exists "$APP")"
|
||||
if [[ "$HAS_NETWORK_CONFIG" == "true" ]]; then
|
||||
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
|
||||
dokku_log_info1 "VHOST support disabled. Skipping domains setup"
|
||||
elif [[ ! -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
|
||||
domains_setup "$APP"
|
||||
fi
|
||||
|
||||
plugn trigger domains-setup "$APP"
|
||||
nginx_build_config "$APP"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ set -eo pipefail
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/certs/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
||||
|
||||
@@ -112,8 +111,9 @@ configure_nginx_ports() {
|
||||
local DOKKU_PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
|
||||
local DOKKU_PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
|
||||
local DOKKU_PROXY_PORT_MAP=$(config_get "$APP" DOKKU_PROXY_PORT_MAP)
|
||||
local IS_APP_VHOST_ENABLED="$(is_app_vhost_enabled "$APP")"
|
||||
local IS_APP_VHOST_ENABLED=true
|
||||
local UPSTREAM_PORT="5000"
|
||||
plugn trigger domains-vhost-enabled "$APP" || IS_APP_VHOST_ENABLED=false
|
||||
|
||||
if [[ -z "$DOKKU_PROXY_PORT" ]] && [[ -z "$RAW_TCP_PORTS" ]]; then
|
||||
if [[ "$IS_APP_VHOST_ENABLED" == "false" ]]; then
|
||||
@@ -164,6 +164,7 @@ validate_ssl_domains() {
|
||||
declare desc="check configured domains against SSL cert contents and show warning if mismatched"
|
||||
local APP=$1
|
||||
verify_app_name "$APP"
|
||||
local VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local SSL_HOSTNAME=$(get_ssl_hostnames "$APP")
|
||||
local SSL_HOSTNAME_REGEX=$(echo "$SSL_HOSTNAME" | xargs | sed 's|\.|\\.|g' | sed 's/\*/\[^\.\]\*/g' | sed 's/ /|/g')
|
||||
|
||||
@@ -317,7 +318,8 @@ nginx_build_config() {
|
||||
local RAW_TCP_PORTS="$(get_app_raw_tcp_ports "$APP")"
|
||||
local DOKKU_APP_LISTENERS
|
||||
|
||||
local IS_APP_VHOST_ENABLED=$(is_app_vhost_enabled "$APP")
|
||||
local IS_APP_VHOST_ENABLED=true
|
||||
plugn trigger domains-vhost-enabled "$APP" || IS_APP_VHOST_ENABLED=false
|
||||
|
||||
if [[ "$(plugn trigger proxy-is-enabled "$APP")" == "true" ]]; then
|
||||
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -z "$DOKKU_APP_LISTEN_IP" ]]; then
|
||||
@@ -342,7 +344,7 @@ nginx_build_config() {
|
||||
local PROXY_UPSTREAM_PORTS="$(echo "$PROXY_UPSTREAM_PORTS" | xargs)"
|
||||
|
||||
local SSL_INUSE=
|
||||
local NONSSL_VHOSTS=$(get_app_domains "$APP")
|
||||
local NONSSL_VHOSTS=$(plugn trigger domains-list "$APP")
|
||||
local NOSSL_SERVER_NAME=$(echo "$NONSSL_VHOSTS" | xargs)
|
||||
if is_ssl_enabled "$APP"; then
|
||||
local SSL_INUSE=true
|
||||
|
||||
@@ -3,6 +3,7 @@ set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
|
||||
|
||||
trigger-nginx-vhosts-post-domains-update() {
|
||||
declare desc="calls nginx build_config when domains are updated"
|
||||
declare trigger="post-domains-update"
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||
|
||||
trigger-nginx-vhosts-proxy-disable() {
|
||||
declare desc="disable nginx proxy"
|
||||
@@ -12,8 +10,8 @@ trigger-nginx-vhosts-proxy-disable() {
|
||||
|
||||
verify_app_name "$APP"
|
||||
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
||||
disable_app_vhost "$APP" --no-restart
|
||||
ps_restart "$APP"
|
||||
plugn trigger domains-disable "$APP" false
|
||||
plugn trigger app-restart "$APP"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||
|
||||
trigger-nginx-vhosts-proxy-enable() {
|
||||
declare desc="enable nginx proxy"
|
||||
@@ -12,8 +10,8 @@ trigger-nginx-vhosts-proxy-enable() {
|
||||
|
||||
verify_app_name "$APP"
|
||||
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
||||
enable_app_vhost "$APP" --no-restart
|
||||
ps_restart "$APP"
|
||||
plugn trigger domains-enable "$APP" "false"
|
||||
plugn trigger app-restart "$APP"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user