refactor: extract release_and_deploy calls to a plugin trigger

Better would be to separate the release and deploy aspects into distinct triggers - as well as have it release a specific image - but this is a good first pass.
This commit is contained in:
Jose Diaz-Gonzalez
2020-10-10 17:32:21 -04:00
committed by Jose Diaz-Gonzalez
parent 1b4559c4a4
commit 696df45306
6 changed files with 28 additions and 5 deletions

View File

@@ -1654,6 +1654,22 @@ fi
plugn trigger receive-app $APP $newrev
```
### `release-and-deploy`
- Description: Triggers a release of the image tag and a subsequent deploy
- Invoked by:
- Arguments: `$APP $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
# TODO
```
### `report`
- Description: Allows you to report on any custom configuration in use by your application

View File

@@ -0,0 +1 @@
hook

View File

@@ -634,7 +634,7 @@ dokku_receive() {
dokku_log_info1 "Building $APP from $IMAGE_SOURCE_TYPE..."
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_APP_TYPE="$IMAGE_SOURCE_TYPE"
dokku_build "$APP" "$IMAGE_SOURCE_TYPE" "$TMP_WORK_DIR"
release_and_deploy "$APP"
plugn trigger release-and-deploy "$APP"
}
docker_cleanup() {

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
release_and_deploy "$@"

View File

@@ -158,7 +158,7 @@ ps_start() {
fi
if [[ "$RUNNING" != "true" ]]; then
release_and_deploy "$APP" "$IMAGE_TAG"
plugn trigger release-and-deploy "$APP" "$IMAGE_TAG"
else
dokku_log_warn "App $APP already running"
fi
@@ -196,7 +196,7 @@ ps_restart() {
local IMAGE_TAG=$(get_running_image_tag "$APP")
if (is_deployed "$APP"); then
release_and_deploy "$APP" "$IMAGE_TAG"
plugn trigger release-and-deploy "$APP" "$IMAGE_TAG"
else
dokku_log_warn "App $APP has not been deployed"
fi
@@ -235,7 +235,7 @@ ps_scale() {
else
if [[ "$(fn-ps-can-scale "$APP")" == "true" ]]; then
set_scale "$APP" "$@"
release_and_deploy "$APP" "$IMAGE_TAG"
plugn trigger release-and-deploy "$APP" "$IMAGE_TAG"
else
dokku_log_fail "App contains DOKKU_SCALE file and cannot be manually scaled"
fi

View File

@@ -14,7 +14,7 @@ cmd-tags-deploy() {
local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")"
verify_image "$IMAGE" || return 1
release_and_deploy "$APP" "$IMAGE_TAG"
plugn trigger release-and-deploy "$APP" "$IMAGE_TAG"
if [[ "$IMAGE_TAG" != "latest" ]]; then
local DOKKU_SCHEDULER="$(get_app_scheduler "$APP")"