feat: unify apps:rename and apps:clone

- add --skip-deploy to apps:rename
- add all missing validation to rename command
- fix log output to be a bit more logical
This commit is contained in:
Jose Diaz-Gonzalez
2020-02-17 19:23:07 -05:00
parent 8987ec6704
commit 2e774f0806
4 changed files with 30 additions and 6 deletions

View File

@@ -134,6 +134,12 @@ Renaming node-js-app to io-js-app... done
This will copy all of your app's contents into a new app directory with the name of your choice, delete your old app, then rebuild the new version of the app and deploy it. All of your config variables, including database urls, will be preserved.
By default, Dokku will deploy the renamed app, though you can skip the deploy by using the `--skip-deploy` flag:
```shell
dokku apps:rename --skip-deploy node-js-app io-js-app
```
### Cloning an existing app
> New as of 0.11.5
@@ -157,7 +163,7 @@ This will copy all of your app's contents into a new app directory with the name
> Warning: If you have exposed specific ports via `docker-options` plugin, or performed anything that cannot be done against multiple applications, `apps:clone` may result in errors.
By default, Dokku will deploy this new application, though you can skip the deploy by using the `--skip-deploy` flag:
By default, Dokku will deploy this new app, though you can skip the deploy by using the `--skip-deploy` flag:
```shell
dokku apps:clone --skip-deploy node-js-app io-js-app

View File

@@ -33,10 +33,11 @@ cmd-apps-clone() {
dokku_log_fail "Name is already taken"
fi
dokku_log_info1_quiet "Cloning $OLD_APP to $NEW_APP"
apps_create "$NEW_APP"
plugn trigger post-app-clone-setup "$OLD_APP" "$NEW_APP"
SKIP_REBUILD=$SKIP_REBUILD plugn trigger post-app-clone "$OLD_APP" "$NEW_APP"
dokku_log_info1_quiet "Cloning $OLD_APP to $NEW_APP... done"
dokku_log_verbose_quiet "Done"
}
cmd-apps-clone "$@"

View File

@@ -10,15 +10,30 @@ cmd-apps-rename() {
declare cmd="apps:rename"
[[ "$1" == "$cmd" ]] && shift 1
declare OLD_APP="$1" NEW_APP="$2"
local SKIP_REBUILD=false
for arg in "$@"; do
[[ "$arg" == "--skip-deploy" ]] && shift 1 && SKIP_REBUILD=true
s [[ "$arg" =~ ^--.* ]] || break
done
OLD_APP="$1" NEW_APP="$2"
[[ -z "$OLD_APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$NEW_APP" ]] && dokku_log_fail "Name is already taken"
is_valid_app_name "$OLD_APP"
is_valid_app_name "$NEW_APP"
apps_exists "$OLD_APP" >/dev/null 2>&1 || dokku_log_fail "App does not exist"
if apps_exists "$NEW_APP" >/dev/null 2>&1; then
dokku_log_fail "Name is already taken"
fi
dokku_log_info1_quiet "Renaming $OLD_APP to $NEW_APP"
apps_create "$NEW_APP"
plugn trigger post-app-rename-setup "$OLD_APP" "$NEW_APP"
DOKKU_APPS_FORCE_DELETE=1 apps_destroy "$OLD_APP"
plugn trigger post-app-rename "$OLD_APP" "$NEW_APP"
echo "Renaming $OLD_APP to $NEW_APP... done"
SKIP_REBUILD=$SKIP_REBUILD plugn trigger post-app-rename "$OLD_APP" "$NEW_APP"
dokku_log_verbose_quiet "Done"
}
cmd-apps-rename "$@"

View File

@@ -10,7 +10,9 @@ trigger-ps-post-app-rename() {
declare trigger="post-app-rename"
declare OLD_APP="$1" NEW_APP="$2"
ps_rebuild "$NEW_APP"
if [[ "$SKIP_REBUILD" != "true" ]]; then
ps_rebuild "$NEW_APP"
fi
}
trigger-ps-post-app-rename "$@"