Merge pull request #8498 from dokku/migrate-env-vars-to-properties
Migrate environment variables to plugin properties
This commit is contained in:
@@ -227,8 +227,8 @@ nginx_build_config() {
|
||||
|
||||
# setup nginx listen ports
|
||||
plugn trigger ports-configure "$APP"
|
||||
local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
|
||||
local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
|
||||
local PROXY_PORT=$(plugn trigger ports-get-property "$APP" "proxy-port")
|
||||
local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port")
|
||||
|
||||
local PORT_MAP PROXY_PORT_MAP proxy_port_map
|
||||
while read -r PORT_MAP; do
|
||||
|
||||
@@ -7,26 +7,8 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
||||
|
||||
fn-nginx-vhosts-migrate-env-vars() {
|
||||
# @TODO: Remove this after a few versions
|
||||
for app in $(dokku_apps "false" 2>/dev/null); do
|
||||
nginx_port="$(config_get "$app" DOKKU_NGINX_PORT || true)"
|
||||
nginx_ssl_port="$(config_get "$app" DOKKU_NGINX_SSL_PORT || true)"
|
||||
if [[ -n "$nginx_port" ]] || [[ -n "$nginx_ssl_port" ]]; then
|
||||
dokku_log_info1 "Migrating DOKKU_NGINX env variables. The following variables will be migrated"
|
||||
dokku_log_info2 "DOKKU_NGINX_PORT -> DOKKU_PROXY_PORT"
|
||||
dokku_log_info2 "DOKKU_NGINX_SSL_PORT -> DOKKU_PROXY_SSL_PORT"
|
||||
fi
|
||||
if [[ -n "$nginx_port" ]]; then
|
||||
dokku_log_info1 "Migrating DOKKU_NGINX_PORT to DOKKU_PROXY_PORT for $app"
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$app" DOKKU_PROXY_PORT="$nginx_port"
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" DOKKU_NGINX_PORT
|
||||
fi
|
||||
if [[ -n "$nginx_ssl_port" ]]; then
|
||||
dokku_log_info1 "Migrating DOKKU_NGINX_SSL_PORT to DOKKU_PROXY_SSL_PORT for $app"
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$app" DOKKU_PROXY_SSL_PORT="$nginx_ssl_port"
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" DOKKU_NGINX_SSL_PORT
|
||||
fi
|
||||
done
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property proxy proxy-port DOKKU_NGINX_PORT
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property proxy proxy-ssl-port DOKKU_NGINX_SSL_PORT
|
||||
}
|
||||
|
||||
fn-nginx-vhosts-migrate-nginx-conf-sigil() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
|
||||
trigger-nginx-vhosts-pre-disable-vhost() {
|
||||
declare desc="unset port prior to vhosts being disabled"
|
||||
@@ -14,19 +14,14 @@ trigger-nginx-vhosts-pre-disable-vhost() {
|
||||
fi
|
||||
|
||||
# only clear ports if they are port 80 or 443
|
||||
local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
|
||||
local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
|
||||
local PROXY_PORT=$(plugn trigger ports-get-property "$APP" "proxy-port")
|
||||
local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port")
|
||||
|
||||
ports_to_clear=()
|
||||
if [[ "$PROXY_PORT" == "80" ]]; then
|
||||
ports_to_clear+=("DOKKU_PROXY_PORT")
|
||||
fn-plugin-property-delete "proxy" "$APP" "proxy-port"
|
||||
fi
|
||||
if [[ "$PROXY_SSL_PORT" == "443" ]]; then
|
||||
ports_to_clear+=("DOKKU_PROXY_SSL_PORT")
|
||||
fi
|
||||
|
||||
if [[ "${#ports_to_clear[@]}" -gt 0 ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" "${ports_to_clear[@]}"
|
||||
fn-plugin-property-delete "proxy" "$APP" "proxy-ssl-port"
|
||||
fi
|
||||
|
||||
# clear ports if there is a mapping starting with http:80 or https:443
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
|
||||
trigger-nginx-vhosts-pre-enable-vhost() {
|
||||
declare desc="unset port prior to vhosts being enabled"
|
||||
@@ -14,19 +14,14 @@ trigger-nginx-vhosts-pre-enable-vhost() {
|
||||
fi
|
||||
|
||||
# only clear ports if they are port 80 or 443
|
||||
local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
|
||||
local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
|
||||
local PROXY_PORT=$(plugn trigger ports-get-property "$APP" "proxy-port")
|
||||
local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port")
|
||||
|
||||
ports_to_clear=()
|
||||
if [[ "$PROXY_PORT" == "80" ]]; then
|
||||
ports_to_clear+=("DOKKU_PROXY_PORT")
|
||||
fn-plugin-property-delete "proxy" "$APP" "proxy-port"
|
||||
fi
|
||||
if [[ "$PROXY_SSL_PORT" == "443" ]]; then
|
||||
ports_to_clear+=("DOKKU_PROXY_SSL_PORT")
|
||||
fi
|
||||
|
||||
if [[ "${#ports_to_clear[@]}" -gt 0 ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" "${ports_to_clear[@]}"
|
||||
fn-plugin-property-delete "proxy" "$APP" "proxy-ssl-port"
|
||||
fi
|
||||
|
||||
# clear ports if there is a mapping starting with http:80 or https:443
|
||||
|
||||
Reference in New Issue
Block a user