From 9736a5ea5b8426bb01b927112b5aea32b9aa67aa Mon Sep 17 00:00:00 2001
From: lukken <lukken@astron.nl>
Date: Wed, 17 Nov 2021 13:10:15 +0000
Subject: [PATCH] L2SS-205: Smart image management in CI pipeline

---
 sbin/tag_and_push_docker_image.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/sbin/tag_and_push_docker_image.sh b/sbin/tag_and_push_docker_image.sh
index 5898e6de3..661ad3158 100755
--- a/sbin/tag_and_push_docker_image.sh
+++ b/sbin/tag_and_push_docker_image.sh
@@ -40,10 +40,13 @@ fi
 # TODO(Corne): Have this list generated from the .yml files
 LOCAL_IMAGES=(
   "elk" "elk-configure-host" "grafana" "prometheus" "lofar-device-base"
-  "docker-compose_jupyter" "docker-compose_integration-test"
-  "docker-compose_itango" "docker-compose_tango-prometheus-exporter"
 )
 
+# TBD TODO(Corne): Verify using these images as cache works
+#  "docker-compose_jupyter" "docker-compose_integration-test"
+#  "docker-compose_itango" "docker-compose_tango-prometheus-exporter"
+#)
+
 # If first argument set run second stage, determine LOCAL_IMAGE to build and
 # push from the argument
 if [ ! -z "${1+x}" ] && [ "${1}" != "pull" ]; then
@@ -82,7 +85,7 @@ fi
 
 # Final stage, pull images for integration cache try special tag image first
 # if it fails download latest instead
-if [ -z "${1+x}" ] && [ "${1}" == "pull" ]; then
+if [ ! -z "${1+x}" ] && [ "${1}" == "pull" ]; then
   echo "Pulling images for integration test cache"
 
   # The second argument must pass the tag variable must be set
@@ -95,8 +98,12 @@ if [ -z "${1+x}" ] && [ "${1}" == "pull" ]; then
   tag="${2}"
 
   for image in "${LOCAL_IMAGES[@]}"; do
+    local_url="${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/${image}"
     docker pull "${local_url}:${tag}" || docker pull "${local_url}:latest"
   done
 
   exit 0
 fi
+
+# Someone nothing ran, that is an error do not fail silently
+exit 1
\ No newline at end of file
-- 
GitLab