Merge pull request #3302 from dokku/locked-command
Add ability to check on app lock status via apps:locked command
This commit is contained in:
7 files changed
+73
-23
No files matched your search
@@ -8,10 +8,11 @@ apps:create <app> # Create a new app
|
|||||||
apps:destroy <app> # Permanently destroy an app
|
apps:destroy <app> # Permanently destroy an app
|
||||||
apps:exists <app> # Checks if an app exists
|
apps:exists <app> # Checks if an app exists
|
||||||
apps:list # List your apps
|
apps:list # List your apps
|
||||||
apps:lock # 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:rename <old-app> <new-app> # Rename an app
|
||||||
apps:report [<app>] [<flag>] # Display report about an app
|
apps:report [<app>] [<flag>] # Display report about an app
|
||||||
apps:unlock # Removes the '.deploy.lock' file from an application's repo
|
apps:unlock <app> # Unlocks an app for deployment
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -193,10 +194,25 @@ dokku apps:unlock node-js-app
|
|||||||
|
|
||||||
```
|
```
|
||||||
! A deploy may be in progress.
|
! A deploy may be in progress.
|
||||||
! Removing the application lock will not stop in progress deploys.
|
! Removing the app lock will not stop in progress deploys.
|
||||||
-----> Deploy lock removed.
|
-----> Deploy lock removed.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Checking lock status
|
||||||
|
|
||||||
|
> New as of 0.13.0
|
||||||
|
|
||||||
|
In some cases, you may wish to inspect the state of an app lock. To do so, you can issue an `apps:lock` command. This will exit non-zero if there is no app lock in place.
|
||||||
|
|
||||||
|
|
||||||
|
```shell
|
||||||
|
dokku apps:locked node-js-app
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
Deploy lock does not exist
|
||||||
|
```
|
||||||
|
|
||||||
### Displaying reports about an app
|
### Displaying reports about an app
|
||||||
|
|
||||||
> New as of 0.8.1
|
> New as of 0.8.1
|
||||||
|
|||||||
@@ -85,10 +85,11 @@ apps_help_content_func() {
|
|||||||
apps:create <app>, Create a new app
|
apps:create <app>, Create a new app
|
||||||
apps:destroy <app>, Permanently destroy an app
|
apps:destroy <app>, Permanently destroy an app
|
||||||
apps:list, List your apps
|
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:rename <old-app> <new-app>, Rename an app
|
||||||
apps:report [<app>] [<flag>], Display report about 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
|
help_content
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,4 +138,4 @@ apps_is_locked() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$LOCKED"
|
echo "$LOCKED"
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|||||||
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
|
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
|
||||||
|
|
||||||
apps_lock_cmd() {
|
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"
|
declare cmd="apps:lock"
|
||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1"; verify_app_name "$APP"
|
declare APP="$1"; verify_app_name "$APP"
|
||||||
|
|||||||
Executable
+20
@@ -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 "$@"
|
||||||
@@ -4,19 +4,19 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|||||||
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
|
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
|
||||||
|
|
||||||
apps_unlock_cmd() {
|
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"
|
declare cmd="apps:unlock"
|
||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1"; verify_app_name "$APP"
|
declare APP="$1"; verify_app_name "$APP"
|
||||||
|
|
||||||
if [[ -f "$DOKKU_ROOT/$APP/.deploy.lock" ]]; then
|
if [[ -f "$DOKKU_ROOT/$APP/.deploy.lock" ]]; then
|
||||||
dokku_log_warn "A deploy may be in progress."
|
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
|
fi
|
||||||
|
|
||||||
rm -f "$DOKKU_ROOT/$APP/.deploy.lock" || dokku_log_fail "Unable to remove deploy lock"
|
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 "$@"
|
apps_unlock_cmd "$@"
|
||||||
+15
-12
@@ -37,8 +37,6 @@ dokku_log_info1_quiet() {
|
|||||||
declare desc="log info1 formatter (with quiet option)"
|
declare desc="log info1 formatter (with quiet option)"
|
||||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||||
echo "-----> $*"
|
echo "-----> $*"
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +44,6 @@ dokku_log_info2_quiet() {
|
|||||||
declare desc="log info2 formatter (with quiet option)"
|
declare desc="log info2 formatter (with quiet option)"
|
||||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||||
echo "=====> $*"
|
echo "=====> $*"
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +56,6 @@ dokku_col_log_info1_quiet() {
|
|||||||
declare desc="columnar log info1 formatter (with quiet option)"
|
declare desc="columnar log info1 formatter (with quiet option)"
|
||||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||||
printf "%-6s %-18s %-25s %-25s %-25s\n" "----->" "$@"
|
printf "%-6s %-18s %-25s %-25s %-25s\n" "----->" "$@"
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +68,6 @@ dokku_col_log_info2_quiet() {
|
|||||||
declare desc="columnar log info2 formatter (with quiet option)"
|
declare desc="columnar log info2 formatter (with quiet option)"
|
||||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||||
printf "%-6s %-18s %-25s %-25s %-25s\n" "=====>" "$@"
|
printf "%-6s %-18s %-25s %-25s %-25s\n" "=====>" "$@"
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +80,6 @@ dokku_col_log_msg_quiet() {
|
|||||||
declare desc="columnar log formatter (with quiet option)"
|
declare desc="columnar log formatter (with quiet option)"
|
||||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||||
printf "%-25s %-25s %-25s %-25s\n" "$@"
|
printf "%-25s %-25s %-25s %-25s\n" "$@"
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,8 +87,6 @@ dokku_log_verbose_quiet() {
|
|||||||
declare desc="log verbose formatter (with quiet option)"
|
declare desc="log verbose formatter (with quiet option)"
|
||||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||||
echo " $*"
|
echo " $*"
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,11 +95,26 @@ dokku_log_verbose() {
|
|||||||
echo " $*"
|
echo " $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dokku_log_warn_quiet() {
|
||||||
|
declare desc="log warning formatter"
|
||||||
|
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||||
|
echo " ! $*" 1>&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
dokku_log_warn() {
|
dokku_log_warn() {
|
||||||
declare desc="log warning formatter"
|
declare desc="log warning formatter"
|
||||||
echo " ! $*" 1>&2
|
echo " ! $*" 1>&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dokku_log_fail_quiet() {
|
||||||
|
declare desc="log fail formatter"
|
||||||
|
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||||
|
echo "$@" 1>&2
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
dokku_log_fail() {
|
dokku_log_fail() {
|
||||||
declare desc="log fail formatter"
|
declare desc="log fail formatter"
|
||||||
echo "$@" 1>&2
|
echo "$@" 1>&2
|
||||||
|
|||||||
+11
-1
@@ -197,7 +197,7 @@ teardown () {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(apps) apps:lock/unlock" {
|
@test "(apps) apps:lock/locked/unlock" {
|
||||||
create_app
|
create_app
|
||||||
|
|
||||||
run bash -c "dokku apps:report $TEST_APP --locked"
|
run bash -c "dokku apps:report $TEST_APP --locked"
|
||||||
@@ -205,6 +205,11 @@ teardown () {
|
|||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_output "false"
|
assert_output "false"
|
||||||
|
|
||||||
|
run bash -c "dokku apps:locked $TEST_APP"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_failure
|
||||||
|
|
||||||
run bash -c "dokku apps:lock $TEST_APP"
|
run bash -c "dokku apps:lock $TEST_APP"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
@@ -215,6 +220,11 @@ teardown () {
|
|||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_output "true"
|
assert_output "true"
|
||||||
|
|
||||||
|
run bash -c "dokku apps:locked $TEST_APP"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
|
||||||
run bash -c "dokku apps:unlock $TEST_APP"
|
run bash -c "dokku apps:unlock $TEST_APP"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
|
|||||||
Reference in new issue
Block a user