From 257abfaee8965dc129602b4ecf8e6c0d6fcbd153 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 13 Aug 2021 01:42:11 -0400 Subject: [PATCH] refactor: move pre-deploy call to post-release-builder Some of the hooks should happen before we push images out... --- plugins/common/functions | 1 - plugins/registry/triggers.go | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/common/functions b/plugins/common/functions index bb6bd1d7f..a4e354fb3 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -657,7 +657,6 @@ cmd-deploy() { verify_app_name "$APP" local DOKKU_SCHEDULER=$(get_app_scheduler "$APP") - plugn trigger pre-deploy "$APP" "$IMAGE_TAG" plugn trigger scheduler-deploy "$DOKKU_SCHEDULER" "$APP" "$IMAGE_TAG" } diff --git a/plugins/registry/triggers.go b/plugins/registry/triggers.go index 547955150..4699d04ee 100644 --- a/plugins/registry/triggers.go +++ b/plugins/registry/triggers.go @@ -61,6 +61,12 @@ func TriggerPostReleaseBuilder(appName string, image string) error { computedImageRepo := reportComputedImageRepo(appName) newImage := strings.Replace(image, imageRepo+":", computedImageRepo+":", 1) + parts := strings.Split(newImage, ":") + imageTag := parts[len(parts)-1] + if err := common.PlugnTrigger("pre-deploy", []string{appName, imageTag}...); err != nil { + return err + } + if computedImageRepo != imageRepo { if !dockerTag(imageID, newImage) { // TODO: better error @@ -73,10 +79,10 @@ func TriggerPostReleaseBuilder(appName string, image string) error { } common.LogInfo1("Pushing image to registry") - imageTag, err := incrementTagVersion(appName) + newTag, err := incrementTagVersion(appName) if err != nil { return err } - return pushToRegistry(appName, imageTag, imageID, computedImageRepo) + return pushToRegistry(appName, newTag, imageID, computedImageRepo) }