From 1a99271fa84a3fd924ce0ed0a7503a8172802b32 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 2 Aug 2021 02:45:41 -0400 Subject: [PATCH] feat: push tag --- plugins/registry/functions.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/registry/functions.go b/plugins/registry/functions.go index 9cf36e696..83bd0cac8 100644 --- a/plugins/registry/functions.go +++ b/plugins/registry/functions.go @@ -3,6 +3,7 @@ package registry import ( "errors" "fmt" + "os" "strconv" "strings" @@ -71,7 +72,10 @@ func pushToRegistry(appName string, tag string) error { // fn-registry-create-repository "$APP" "$DOKKU_REGISTRY_SERVER" "$IMAGE_REPO" common.LogVerboseQuiet("Pushing $IMAGE_REPO:$TAG") - // docker push "${DOKKU_REGISTRY_SERVER}${IMAGE_REPO}:${TAG}" + if !dockerPush(fmt.Sprintf("%s%s:%s", registryServer, imageRepo, tag)) { + // TODO: better error + return errors.New("Unable to push image") + } common.LogVerboseQuiet("Cleaning up") // fn-registry-image-cleanup "$APP" "$DOKKU_REGISTRY_SERVER" "$IMAGE_REPO" "$IMAGE_TAG" "$TAG" @@ -90,3 +94,14 @@ func dockerTag(imageID string, imageTag string) bool { return true } + +func dockerPush(imageTag string) bool { + cmd := sh.Command(common.DockerBin(), "image", "push", imageTag) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Run(); err != nil { + return false + } + + return true +}