Merge pull request #8498 from dokku/migrate-env-vars-to-properties
Migrate environment variables to plugin properties
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
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"
|
||||
|
||||
is_app_proctype_checks_disabled() {
|
||||
declare desc="return true if app's proctype(s) checks are disabled"
|
||||
local APP="$1"
|
||||
local PROCTYPE="$2" status=false
|
||||
local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED || true)
|
||||
local DOKKU_CHECKS_DISABLED=$(fn-plugin-property-get-default "checks" "$APP" "disabled" "")
|
||||
|
||||
if [[ "$DOKKU_CHECKS_DISABLED" == "_all_" ]] || [[ "$(is_val_in_list "$PROCTYPE" "$DOKKU_CHECKS_DISABLED")" == "true" ]]; then
|
||||
status=true
|
||||
@@ -21,7 +21,7 @@ is_app_proctype_checks_skipped() {
|
||||
declare desc="return true if app's proctype(s) checks are skipped"
|
||||
local APP="$1"
|
||||
local PROCTYPE="$2" status=false
|
||||
local DOKKU_CHECKS_SKIPPED=$(config_get "$APP" DOKKU_CHECKS_SKIPPED || true)
|
||||
local DOKKU_CHECKS_SKIPPED=$(fn-plugin-property-get-default "checks" "$APP" "skipped" "")
|
||||
|
||||
if [[ "$DOKKU_CHECKS_SKIPPED" == "_all_" ]] || [[ "$(is_val_in_list "$PROCTYPE" "$DOKKU_CHECKS_SKIPPED")" == "true" ]]; then
|
||||
status=true
|
||||
|
||||
@@ -3,16 +3,14 @@ set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
migrate_checks_vars_0_29_0() {
|
||||
declare desc="migrates deprecated DOKKU_WAIT_TO_RETIRE config variables to property counter part introduced in 0.29.x"
|
||||
|
||||
fn-migrate-config-to-property "checks" "wait-to-retire" "DOKKU_WAIT_TO_RETIRE" "DOKKU_WAIT_TO_RETIRE"
|
||||
}
|
||||
|
||||
migrate_checks_vars_0_5_0() {
|
||||
declare desc="migrates deprecated CHECKS config variables to simplified counter part introduced in 0.5.x"
|
||||
|
||||
if ! declare -f -F config_get >/dev/null; then
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
fi
|
||||
|
||||
local GLOBAL_SKIP_ALL_CHECKS=$(config_get --global DOKKU_SKIP_ALL_CHECKS || true)
|
||||
local GLOBAL_SKIP_DEFAULT_CHECKS=$(config_get --global DOKKU_SKIP_DEFAULT_CHECKS || true)
|
||||
|
||||
@@ -20,13 +18,13 @@ migrate_checks_vars_0_5_0() {
|
||||
local APP_SKIP_ALL_CHECKS=$(config_get "$app" DOKKU_SKIP_ALL_CHECKS || true)
|
||||
local APP_SKIP_DEFAULT_CHECKS=$(config_get "$app" DOKKU_SKIP_DEFAULT_CHECKS || true)
|
||||
|
||||
if [[ "$APP_SKIP_ALL_CHECKS" == "true" ]] || [[ "$APP_SKIP_DEFAULT_CHECKS" == "true" ]] || [[ "$GLOBAL_SKIP_ALL_CHECKS" == "true" ]] || [[ "$GLOBAL_SKIP_DEFAULT_CHECKS" == "true" ]]; then
|
||||
dokku_log_info1 "Migrating zero downtime env variables to 0.5.x. The following variables have been deprecated"
|
||||
dokku_log_info2 "DOKKU_SKIP_ALL_CHECKS DOKKU_SKIP_DEFAULT_CHECKS"
|
||||
dokku_log_info2 "Please use dokku checks:[disable|enable] <app> to control zero downtime functionality"
|
||||
dokku_log_info2 ""
|
||||
dokku_log_info2 "Zero downtime checks disabled for app ($app)"
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$app" DOKKU_CHECKS_ENABLED=0
|
||||
if [[ "$APP_SKIP_ALL_CHECKS" == "true" ]] || [[ "$GLOBAL_SKIP_ALL_CHECKS" == "true" ]]; then
|
||||
dokku_log_info1 "Migrating DOKKU_SKIP_ALL_CHECKS to checks disabled property for $app. Use 'dokku checks:set $app disabled <value>' to manage this going forward."
|
||||
fn-plugin-property-write "checks" "$app" "disabled" "_all_"
|
||||
fi
|
||||
if [[ "$APP_SKIP_DEFAULT_CHECKS" == "true" ]] || [[ "$GLOBAL_SKIP_DEFAULT_CHECKS" == "true" ]]; then
|
||||
dokku_log_info1 "Migrating DOKKU_SKIP_DEFAULT_CHECKS to checks skipped property for $app. Use 'dokku checks:set $app skipped <value>' to manage this going forward."
|
||||
fn-plugin-property-write "checks" "$app" "skipped" "_all_"
|
||||
fi
|
||||
if [[ -n "$APP_SKIP_ALL_CHECKS" ]] || [[ -n "$APP_SKIP_DEFAULT_CHECKS" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" DOKKU_SKIP_ALL_CHECKS DOKKU_SKIP_DEFAULT_CHECKS
|
||||
@@ -34,7 +32,6 @@ migrate_checks_vars_0_5_0() {
|
||||
done
|
||||
|
||||
if [[ -n "$GLOBAL_SKIP_ALL_CHECKS" ]] || [[ -n "$GLOBAL_SKIP_DEFAULT_CHECKS" ]]; then
|
||||
dokku_log_info1 "Removing global zero downtime settings"
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --global DOKKU_SKIP_ALL_CHECKS DOKKU_SKIP_DEFAULT_CHECKS
|
||||
fi
|
||||
}
|
||||
@@ -42,15 +39,16 @@ migrate_checks_vars_0_5_0() {
|
||||
migrate_checks_vars_0_6_0() {
|
||||
declare desc="migrates CHECKS config variables from 0.5.x to support fully-disabled zero-downtime checks"
|
||||
|
||||
if ! declare -f -F config_get >/dev/null; then
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
fi
|
||||
|
||||
for app in $(dokku_apps "false" 2>/dev/null); do
|
||||
local APP_DOKKU_CHECKS_ENABLED=$(config_get "$app" DOKKU_CHECKS_ENABLED || true)
|
||||
if [[ $APP_DOKKU_CHECKS_ENABLED ]]; then
|
||||
dokku_log_info1 "Migrating zero downtime env variables to 0.6.x. The following variables will be migrated"
|
||||
dokku_log_info2 "DOKKU_CHECKS_ENABLED -> DOKKU_CHECKS_SKIPPED"
|
||||
if [[ -n "$APP_DOKKU_CHECKS_ENABLED" ]]; then
|
||||
if [[ "$APP_DOKKU_CHECKS_ENABLED" == "0" ]]; then
|
||||
dokku_log_info2 ""
|
||||
dokku_log_info2 "Zero downtime checks disabled for app ($app)"
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$app" DOKKU_CHECKS_SKIPPED="_all_"
|
||||
dokku_log_info1 "Migrating DOKKU_CHECKS_ENABLED to checks skipped property for $app. Use 'dokku checks:set $app skipped <value>' to manage this going forward."
|
||||
fn-plugin-property-write "checks" "$app" "skipped" "_all_"
|
||||
fi
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" DOKKU_CHECKS_ENABLED || true
|
||||
fi
|
||||
@@ -64,7 +62,14 @@ trigger-checks-install() {
|
||||
fn-plugin-property-setup "checks"
|
||||
migrate_checks_vars_0_5_0 "$@"
|
||||
migrate_checks_vars_0_6_0 "$@"
|
||||
migrate_checks_vars_0_29_0 "$@"
|
||||
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property checks wait-to-retire DOKKU_WAIT_TO_RETIRE --global-config-var DOKKU_WAIT_TO_RETIRE
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property checks disabled DOKKU_CHECKS_DISABLED
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property checks skipped DOKKU_CHECKS_SKIPPED
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property checks wait DOKKU_CHECKS_WAIT --global-config-var DOKKU_CHECKS_WAIT
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property checks timeout DOKKU_CHECKS_TIMEOUT --global-config-var DOKKU_CHECKS_TIMEOUT
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property checks attempts DOKKU_CHECKS_ATTEMPTS --global-config-var DOKKU_CHECKS_ATTEMPTS
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property checks default-wait DOKKU_DEFAULT_CHECKS_WAIT --global-config-var DOKKU_DEFAULT_CHECKS_WAIT
|
||||
}
|
||||
|
||||
trigger-checks-install "$@"
|
||||
|
||||
@@ -72,7 +72,7 @@ cmd-checks-report-single() {
|
||||
fn-checks-disabled-list() {
|
||||
declare APP="$1"
|
||||
|
||||
local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED)
|
||||
local DOKKU_CHECKS_DISABLED=$(fn-plugin-property-get-default "checks" "$APP" "disabled" "")
|
||||
DOKKU_CHECKS_DISABLED="${DOKKU_CHECKS_DISABLED:-none}"
|
||||
echo "$DOKKU_CHECKS_DISABLED"
|
||||
}
|
||||
@@ -80,7 +80,7 @@ fn-checks-disabled-list() {
|
||||
fn-checks-skipped-list() {
|
||||
declare APP="$1"
|
||||
|
||||
local DOKKU_CHECKS_SKIPPED=$(config_get "$APP" DOKKU_CHECKS_SKIPPED)
|
||||
local DOKKU_CHECKS_SKIPPED=$(fn-plugin-property-get-default "checks" "$APP" "skipped" "")
|
||||
DOKKU_CHECKS_SKIPPED="${DOKKU_CHECKS_SKIPPED:-none}"
|
||||
echo "$DOKKU_CHECKS_SKIPPED"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
|
||||
cmd-checks-disable() {
|
||||
declare desc="disable zero-downtime checks for app/proctypes"
|
||||
@@ -12,13 +12,13 @@ cmd-checks-disable() {
|
||||
|
||||
verify_app_name "$APP"
|
||||
local PROCTYPES="${2:-_all_}"
|
||||
local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED || true)
|
||||
local DOKKU_CHECKS_SKIPPED=$(config_get "$APP" DOKKU_CHECKS_SKIPPED || true)
|
||||
local DOKKU_CHECKS_DISABLED=$(fn-plugin-property-get-default "checks" "$APP" "disabled" "")
|
||||
local DOKKU_CHECKS_SKIPPED=$(fn-plugin-property-get-default "checks" "$APP" "skipped" "")
|
||||
|
||||
if [[ "$PROCTYPES" == "_all_" ]]; then
|
||||
dokku_log_info1 "Disabling zero downtime for app ($APP)"
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_CHECKS_DISABLED="$PROCTYPES"
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_SKIPPED
|
||||
fn-plugin-property-write "checks" "$APP" "disabled" "$PROCTYPES"
|
||||
fn-plugin-property-delete "checks" "$APP" "skipped"
|
||||
else
|
||||
dokku_log_info1 "Disabling zero downtime for app's ($APP) proctypes ($PROCTYPES)"
|
||||
local PROCTYPE OIFS="$IFS" IFS=,
|
||||
@@ -31,15 +31,15 @@ cmd-checks-disable() {
|
||||
done
|
||||
DOKKU_CHECKS_DISABLED="$(remove_val_from_list "_all_" "$DOKKU_CHECKS_DISABLED")"
|
||||
if [[ -z "$DOKKU_CHECKS_DISABLED" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_DISABLED
|
||||
fn-plugin-property-delete "checks" "$APP" "disabled"
|
||||
else
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_CHECKS_DISABLED="$DOKKU_CHECKS_DISABLED"
|
||||
fn-plugin-property-write "checks" "$APP" "disabled" "$DOKKU_CHECKS_DISABLED"
|
||||
fi
|
||||
|
||||
if [[ -z "$DOKKU_CHECKS_SKIPPED" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_SKIPPED
|
||||
fn-plugin-property-delete "checks" "$APP" "skipped"
|
||||
else
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_CHECKS_SKIPPED="$DOKKU_CHECKS_SKIPPED"
|
||||
fn-plugin-property-write "checks" "$APP" "skipped" "$DOKKU_CHECKS_SKIPPED"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
|
||||
cmd-checks-enable() {
|
||||
declare desc="enable zero-downtime checks for app/proctypes"
|
||||
@@ -13,13 +13,13 @@ cmd-checks-enable() {
|
||||
verify_app_name "$APP"
|
||||
local PROCTYPES="${2:-_all_}"
|
||||
|
||||
local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED || true)
|
||||
local DOKKU_CHECKS_SKIPPED=$(config_get "$APP" DOKKU_CHECKS_SKIPPED || true)
|
||||
local DOKKU_CHECKS_DISABLED=$(fn-plugin-property-get-default "checks" "$APP" "disabled" "")
|
||||
local DOKKU_CHECKS_SKIPPED=$(fn-plugin-property-get-default "checks" "$APP" "skipped" "")
|
||||
|
||||
if [[ "$PROCTYPES" == "_all_" ]]; then
|
||||
dokku_log_info1 "Enabling zero downtime for app's ($APP)"
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_DISABLED
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_SKIPPED
|
||||
fn-plugin-property-delete "checks" "$APP" "disabled"
|
||||
fn-plugin-property-delete "checks" "$APP" "skipped"
|
||||
else
|
||||
dokku_log_info1 "Enabling zero downtime for app's ($APP) proctypes ($PROCTYPES)"
|
||||
local PROCTYPE OIFS="$IFS" IFS=,
|
||||
@@ -30,15 +30,15 @@ cmd-checks-enable() {
|
||||
|
||||
IFS="$OIFS"
|
||||
if [[ -z "$DOKKU_CHECKS_DISABLED" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_DISABLED
|
||||
fn-plugin-property-delete "checks" "$APP" "disabled"
|
||||
else
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_CHECKS_DISABLED="$DOKKU_CHECKS_DISABLED"
|
||||
fn-plugin-property-write "checks" "$APP" "disabled" "$DOKKU_CHECKS_DISABLED"
|
||||
fi
|
||||
|
||||
if [[ -z "$DOKKU_CHECKS_SKIPPED" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_SKIPPED
|
||||
fn-plugin-property-delete "checks" "$APP" "skipped"
|
||||
else
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_CHECKS_SKIPPED="$DOKKU_CHECKS_SKIPPED"
|
||||
fn-plugin-property-write "checks" "$APP" "skipped" "$DOKKU_CHECKS_SKIPPED"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
|
||||
cmd-checks-skip() {
|
||||
declare desc="skip zero-downtime checks for app/proctypes"
|
||||
@@ -12,13 +12,13 @@ cmd-checks-skip() {
|
||||
|
||||
verify_app_name "$APP"
|
||||
local PROCTYPES="${2:-_all_}"
|
||||
local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED || true)
|
||||
local DOKKU_CHECKS_SKIPPED=$(config_get "$APP" DOKKU_CHECKS_SKIPPED || true)
|
||||
local DOKKU_CHECKS_DISABLED=$(fn-plugin-property-get-default "checks" "$APP" "disabled" "")
|
||||
local DOKKU_CHECKS_SKIPPED=$(fn-plugin-property-get-default "checks" "$APP" "skipped" "")
|
||||
|
||||
if [[ "$PROCTYPES" == "_all_" ]]; then
|
||||
dokku_log_info1 "Skipping zero downtime for app ($APP)"
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_CHECKS_SKIPPED="$PROCTYPES"
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_DISABLED
|
||||
fn-plugin-property-write "checks" "$APP" "skipped" "$PROCTYPES"
|
||||
fn-plugin-property-delete "checks" "$APP" "disabled"
|
||||
else
|
||||
dokku_log_info1 "Skipping zero downtime for app's ($APP) proctypes ($PROCTYPES)"
|
||||
local PROCTYPE OIFS="$IFS" IFS=,
|
||||
@@ -31,15 +31,15 @@ cmd-checks-skip() {
|
||||
done
|
||||
DOKKU_CHECKS_SKIPPED="$(remove_val_from_list "_all_" "$DOKKU_CHECKS_SKIPPED")"
|
||||
if [[ -z "$DOKKU_CHECKS_DISABLED" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_DISABLED
|
||||
fn-plugin-property-delete "checks" "$APP" "disabled"
|
||||
else
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_CHECKS_DISABLED="$DOKKU_CHECKS_DISABLED"
|
||||
fn-plugin-property-write "checks" "$APP" "disabled" "$DOKKU_CHECKS_DISABLED"
|
||||
fi
|
||||
|
||||
if [[ -z "$DOKKU_CHECKS_SKIPPED" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_CHECKS_SKIPPED
|
||||
fn-plugin-property-delete "checks" "$APP" "skipped"
|
||||
else
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_CHECKS_SKIPPED="$DOKKU_CHECKS_SKIPPED"
|
||||
fn-plugin-property-write "checks" "$APP" "skipped" "$DOKKU_CHECKS_SKIPPED"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user