From 6609af6abc6a2b38a5c51fe721995d290f11b968 Mon Sep 17 00:00:00 2001
From: Alexander Wellbrock <a.wellbrock@mailbox.org>
Date: Thu, 14 Jan 2021 14:29:44 +0100
Subject: [PATCH] extend push tooling by manifest type

The push tool will now perform a simple check if the image reference is
of type manifest and will invoke the correct command for that.

The --all parameter is used to push all images on the local machine
referenced in the manifest which has shown to reduce errors at
registries.

The --format v2s2 tag is crucial to push the manifest in docker format
which is the only supported format of quay.io.
---
 resources/shell-tools/bin/push.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/resources/shell-tools/bin/push.sh b/resources/shell-tools/bin/push.sh
index d6f7f9b..4bdd009 100755
--- a/resources/shell-tools/bin/push.sh
+++ b/resources/shell-tools/bin/push.sh
@@ -26,8 +26,15 @@ printUsage() {
     exit 1
 }
 
-CONTAINER_CMD=podman
+pushImageOrManifest() {
+    if podman manifest inspect "$1"; then
+        $CONTAINER_CMD manifest push --all --format v2s2 "$1" "docker://$1"
+    else
+        $CONTAINER_CMD push "$1"
+    fi
+}
 
+CONTAINER_CMD=podman
 
 if ! command -v "$CONTAINER_CMD" >/dev/null 2>&1; then
     CONTAINER_CMD=docker
@@ -67,4 +74,4 @@ if [ "$CONTAINER_IMAGE_NAME" = "invalid" ]; then
 fi
 
 # shellcheck disable=SC2086
-$CONTAINER_CMD images --format "{{.Repository}}:{{.Tag}}" "$CONTAINER_IMAGE_NAME" | grep "$CONTAINER_IMAGE_NAME" | xargs -L 1 $CONTAINER_CMD push
+$CONTAINER_CMD images --format "{{.Repository}}:{{.Tag}}" "$CONTAINER_IMAGE_NAME" | grep "$CONTAINER_IMAGE_NAME" | xargs -L 1 pushImageOrManifest
-- 
GitLab