subcommand restructure and bashstyle refactor. closes #1579

This commit is contained in:
Michael S. Hobbs
2016-03-01 13:26:35 -08:00
committed by Michael Hobbs
parent 76e27f0333
commit 89f289b433
105 changed files with 1969 additions and 1306 deletions

View File

@@ -78,6 +78,7 @@ docker cp $DOKKU_APP_CONTAINER_ID:/app/CHECKS "$TMPDIR" 2> /dev/null || true
FILENAME=${TMPDIR}/CHECKS
cleanup() {
local desc="cleans up TMPDIR and print container output"
rm -rf "$TMPDIR"
dokku_log_info2_quiet "$APP container output:"
dokku_container_log_verbose_quiet $DOKKU_APP_CONTAINER_ID

View File

@@ -1,67 +1,8 @@
#!/usr/bin/env bash
[[ " checks checks:enable checks:disable help ps:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
[[ " help checks:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
checks_main() {
local desc="displays app zero-downtime status"
local ALL_APPS=$(dokku_apps)
if [[ -n "$1" ]]; then
local APP="$1"
fi
local APPS=${APP:="$ALL_APPS"}
dokku_col_log_info1_quiet "App Name" "Zero-Downtime Status"
for app in $APPS; do
verify_app_name "$app"
dokku_col_log_msg "$app" "$(is_app_checks_enabled "$app")"
done
}
checks_enable() {
local desc="enable zero-downtime for app"
local APP="$1"; verify_app_name "$APP"
if [[ "$(is_app_checks_enabled "$APP")" == "false" ]]; then
dokku_log_info1 "Enabling zero downtime for app ($APP)"
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
# shellcheck disable=SC2086
config_set $CONFIG_SET_ARGS $APP DOKKU_CHECKS_ENABLED=1
else
dokku_log_info1 "zero downtime is already enabled for app ($APP)"
fi
}
checks_disable() {
local desc="disable zero-downtime for app"
local APP="$1"; verify_app_name "$APP"
if [[ "$(is_app_checks_enabled "$APP")" == "true" ]]; then
dokku_log_info1 "Disabling zero downtime for app ($APP)"
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
# shellcheck disable=SC2086
config_set $CONFIG_SET_ARGS $APP DOKKU_CHECKS_ENABLED=0
else
dokku_log_info1 "zero downtime is already disable for app ($APP)"
fi
}
case "$1" in
checks)
checks_main "$2"
;;
checks:enable)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
checks_enable "$2" --no-restart
;;
checks:disable)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
checks_disable "$2" --no-restart
;;
help | ps:help)
cat<<EOF
checks <app>, Show zero-downtime status

View File

@@ -4,6 +4,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
migrate_checks_vars() {
local desc="migrates deprecated CHECKS config variables to simplified counter part introduced in 0.5.x"
local APPS="$(dokku_apps)"
local GLOBAL_SKIP_ALL_CHECKS=$(dokku config:get --global DOKKU_SKIP_ALL_CHECKS || true)
local GLOBAL_SKIP_DEFAULT_CHECKS=$(dokku config:get --global DOKKU_SKIP_DEFAULT_CHECKS || true)

View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
checks_main_cmd() {
local desc="displays app zero-downtime status"
local cmd="checks"
local ALL_APPS=$(dokku_apps)
if [[ -n "$1" ]]; then
local APP="$1"
fi
local APPS=${APP:="$ALL_APPS"}
dokku_col_log_info1_quiet "App Name" "Zero-Downtime Status"
local app
for app in $APPS; do
verify_app_name "$app"
dokku_col_log_msg "$app" "$(is_app_checks_enabled "$app")"
done
}
checks_main_cmd "$2"

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
checks_disable_cmd() {
local desc="disable zero-downtime for app"
local cmd="check:disable"
local APP="$1"; verify_app_name "$APP"
if [[ "$(is_app_checks_enabled "$APP")" == "true" ]]; then
dokku_log_info1 "Disabling zero downtime for app ($APP)"
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
# shellcheck disable=SC2086
config_set $CONFIG_SET_ARGS $APP DOKKU_CHECKS_ENABLED=0
else
dokku_log_info1 "zero downtime is already disable for app ($APP)"
fi
}
checks_disable_cmd "$2" --no-restart

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
checks_enable_cmd() {
local desc="enable zero-downtime for app"
local cmd="checks:enable"
local APP="$1"; verify_app_name "$APP"
if [[ "$(is_app_checks_enabled "$APP")" == "false" ]]; then
dokku_log_info1 "Enabling zero downtime for app ($APP)"
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
# shellcheck disable=SC2086
config_set $CONFIG_SET_ARGS $APP DOKKU_CHECKS_ENABLED=1
else
dokku_log_info1 "zero downtime is already enabled for app ($APP)"
fi
}
checks_enable_cmd "$2" --no-restart