Merge pull request #3085 from dokku/app-clone-enhancements
feat: add support for checking if an application exists
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
apps:clone <old-app> <new-app> # Clones an app
|
||||
apps:create <app> # Create a new app
|
||||
apps:destroy <app> # Permanently destroy an app
|
||||
apps:exists <app> # Checks if an app exists
|
||||
apps:list # List your apps
|
||||
apps:rename <old-app> <new-app> # Rename an app
|
||||
apps:report [<app>] [<flag>] # Display report about an app
|
||||
@@ -40,6 +41,20 @@ node-js-app
|
||||
python-app
|
||||
```
|
||||
|
||||
### Checking if an application exists
|
||||
|
||||
For CI/CD pipelines, it may be useful to see if an application exists before creating a "review" application for a specific branch. You can do so via the `apps:exists` command:
|
||||
|
||||
```shell
|
||||
dokku apps:exists node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
App does not exist
|
||||
```
|
||||
|
||||
The `apps:exists` command will return non-zero if the application does not exist, and zero if it does.
|
||||
|
||||
### Manually creating an application
|
||||
|
||||
A common pattern for deploying applications to Dokku is to configure an application before deploying it. You can do so via the `apps:create` command:
|
||||
|
||||
@@ -49,3 +49,12 @@ apps_destroy() {
|
||||
|
||||
plugn trigger post-delete "$APP" "$IMAGE_TAG"
|
||||
}
|
||||
|
||||
apps_exists() {
|
||||
declare desc="checks if an app exists"
|
||||
declare APP="$1"
|
||||
is_valid_app_name "$APP"
|
||||
|
||||
[[ -d "$DOKKU_ROOT/$APP" ]] || dokku_log_fail "App does not exist"
|
||||
dokku_log_info1 "App already exists"
|
||||
}
|
||||
|
||||
11
plugins/apps/subcommands/exists
Executable file
11
plugins/apps/subcommands/exists
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
|
||||
|
||||
apps_exists_cmd() {
|
||||
declare desc="checks if an app exists"
|
||||
local cmd="apps:exists"
|
||||
apps_exists "$2"
|
||||
}
|
||||
|
||||
apps_exists_cmd "$@"
|
||||
@@ -132,3 +132,22 @@ teardown () {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(apps) apps:exists" {
|
||||
run dokku apps:exists $TEST_APP
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
|
||||
create_app
|
||||
run dokku apps:exists $TEST_APP
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku --force apps:destroy $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user