feat: add subcommands to allow app locking and unlocking
Unlocking an app will not stop running deploys, so users may need to clean up. However, it is useful for deploys that fail in unusual ways that cause the lock to stay around. Closes #2883
This commit is contained in:
@@ -10,8 +10,10 @@ 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: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
|
||||
help_content
|
||||
}
|
||||
|
||||
@@ -49,3 +51,15 @@ apps_list_cmd() {
|
||||
echo "$app"
|
||||
done
|
||||
}
|
||||
|
||||
apps_is_locked() {
|
||||
declare desc="check if an app is locked"
|
||||
declare APP="$1"
|
||||
local LOCKED=false
|
||||
|
||||
if [[ -f "$DOKKU_ROOT/$APP/.deploy.lock" ]]; then
|
||||
LOCKED=true
|
||||
fi
|
||||
|
||||
echo "$LOCKED"
|
||||
}
|
||||
17
plugins/apps/subcommands/lock
Executable file
17
plugins/apps/subcommands/lock
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/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_lock_cmd() {
|
||||
declare desc="creates a '.deploy.lock' file in an application's repo"
|
||||
declare cmd="apps:lock"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1"; verify_app_name "$APP"
|
||||
|
||||
touch "$DOKKU_ROOT/$APP/.deploy.lock" || dokku_log_fail "Unable to create deploy lock"
|
||||
|
||||
dokku_log_info1 "Deploy lock created"
|
||||
}
|
||||
|
||||
apps_lock_cmd "$@"
|
||||
@@ -2,6 +2,7 @@
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
|
||||
|
||||
report_single_app() {
|
||||
declare APP="$1" INFO_FLAG="$2"
|
||||
@@ -16,6 +17,7 @@ report_single_app() {
|
||||
"--app-dir: $APP_DIR"
|
||||
"--git-sha: $(GIT_DIR="$APP_DIR" git rev-parse --short HEAD 2> /dev/null || false)"
|
||||
"--deploy-source: $(: | plugn trigger deploy-source "$APP")"
|
||||
"--locked: $(apps_is_locked "$APP")"
|
||||
)
|
||||
|
||||
if [[ -z "$INFO_FLAG" ]]; then
|
||||
|
||||
22
plugins/apps/subcommands/unlock
Executable file
22
plugins/apps/subcommands/unlock
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/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_unlock_cmd() {
|
||||
declare desc="removes the '.deploy.lock' file from an application's repo"
|
||||
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."
|
||||
fi
|
||||
|
||||
rm -f "$DOKKU_ROOT/$APP/.deploy.lock" || dokku_log_fail "Unable to remove deploy lock"
|
||||
|
||||
dokku_log_info1 "Deploy lock removed."
|
||||
}
|
||||
|
||||
apps_unlock_cmd "$@"
|
||||
Reference in New Issue
Block a user