From af7259dbc1e60d306d45a1b38ceffef183bb5ce5 Mon Sep 17 00:00:00 2001 From: Ales Raszka Date: Fri, 15 Sep 2023 13:17:28 +0200 Subject: [PATCH] Add permanent tag to new index images The permanent tag make sure the index image is not deleted after a new index is released. The permanent tag is made of version + epoch timestamp. JIRA: ISV-3996 Signed-off-by: Ales Raszka --- .../openshift/tasks/publish-to-index.yml | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ansible/roles/operator-pipeline/templates/openshift/tasks/publish-to-index.yml b/ansible/roles/operator-pipeline/templates/openshift/tasks/publish-to-index.yml index 82d6a1b8f..0879719d2 100644 --- a/ansible/roles/operator-pipeline/templates/openshift/tasks/publish-to-index.yml +++ b/ansible/roles/operator-pipeline/templates/openshift/tasks/publish-to-index.yml @@ -79,19 +79,35 @@ spec: TEMP_IMAGES=$(echo $(params.index_image_paths) | tr "," " ") + SUFFIX=`date +%s` + for i in $TEMP_IMAGES do SRC_IMAGE=$(echo $i | awk -F '+' '{print $2}') echo "Source image: $SRC_IMAGE" VERSION=$(echo $i | awk -F '+' '{print $1}' | awk -F ':' '{print $2}') - DEST_IMAGE="${FROM_INDEX}:${VERSION}" - echo "Dest image: $DEST_IMAGE" + DEST_IMAGE_VERSION_TAG="${FROM_INDEX}:${VERSION}" + DEST_IMAGE_PERMANENT_TAG="${DEST_IMAGE_VERSION_TAG}-${SUFFIX}" + + echo "Dest images:" + echo " - $DEST_IMAGE_VERSION_TAG" + echo " - $DEST_IMAGE_PERMANENT_TAG" + + # Add version tag to an index + skopeo \ + --command-timeout 300s copy \ + --format v2s2 --all \ + --src-no-creds \ + --dest-creds $QUAY_USER:$QUAY_TOKEN \ + docker://$SRC_IMAGE \ + docker://$DEST_IMAGE_VERSION_TAG + # Add permanent tag to an index skopeo \ --command-timeout 300s copy \ --format v2s2 --all \ --src-no-creds \ --dest-creds $QUAY_USER:$QUAY_TOKEN \ docker://$SRC_IMAGE \ - docker://$DEST_IMAGE + docker://$DEST_IMAGE_PERMANENT_TAG done