feat: add ability to check on app lock status via apps:locked command

This allows users to further introspect on the state of the application.
This commit is contained in:
Jose Diaz-Gonzalez
2018-11-05 01:20:34 -05:00
parent 6b35cc3131
commit cb3b5bdc28
7 changed files with 73 additions and 23 deletions

View File

@@ -85,10 +85,11 @@ apps_help_content_func() {
apps:create <app>, Create a new app
apps:destroy <app>, Permanently destroy an app
apps:list, List your apps
apps:lock <app>, Creates a '.deploy.lock' file in an application's repo
apps:lock <app>, Locks an app for deployment
apps:locked <app>, Checks if an app is locked for deployment
apps:rename <old-app> <new-app>, Rename an app
apps:report [<app>] [<flag>], Display report about an app
apps:unlock <app>, Removes the '.deploy.lock' file from an application's repo
apps:unlock <app>, Unlocks an app for deployment
help_content
}
@@ -137,4 +138,4 @@ apps_is_locked() {
fi
echo "$LOCKED"
}
}

View File

@@ -4,7 +4,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
apps_lock_cmd() {
declare desc="creates a '.deploy.lock' file in an application's repo"
declare desc="locks an app for deployment"
declare cmd="apps:lock"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"; verify_app_name "$APP"

20
plugins/apps/subcommands/locked Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
apps_locked_cmd() {
declare desc="checks if an app is locked for deployment"
declare cmd="apps:locked"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"; verify_app_name "$APP"
local LOCKED="$(apps_is_locked "$APP")"
if [[ "$LOCKED" != "true" ]] ; then
dokku_log_fail_quiet "Deploy lock does not exist"
fi
dokku_log_quiet "Deploy lock exists"
}
apps_locked_cmd "$@"

View File

@@ -4,19 +4,19 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
apps_unlock_cmd() {
declare desc="removes the '.deploy.lock' file from an application's repo"
declare desc="unlocks an app for deployment"
declare cmd="apps:unlock"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"; verify_app_name "$APP"
if [[ -f "$DOKKU_ROOT/$APP/.deploy.lock" ]]; then
dokku_log_warn "A deploy may be in progress."
dokku_log_warn "Removing the application lock will not stop in progress deploys."
dokku_log_warn "Removing the app lock will not stop in progress deploys."
fi
rm -f "$DOKKU_ROOT/$APP/.deploy.lock" || dokku_log_fail "Unable to remove deploy lock"
dokku_log_info1 "Deploy lock removed."
dokku_log_info1 "Deploy lock removed"
}
apps_unlock_cmd "$@"