Skip to content

Commit

Permalink
feat(RHTAPREL-816): add translate-delivery-repo utility
Browse files Browse the repository at this point in the history
This commit adds the translate-delivery-repo to translate
quay.io/redhat-prod/product----repo into registry.redhat.io/product/repo
and quay.io/redhat-pending/product----repo into
registry.stage.redhat.io/product/repo. This translation will need to be
done in multiple places, so it should be stored as a utility in this
image instead of repeating the logic in multiple locations.

Signed-off-by: Johnny Bieren <[email protected]>
  • Loading branch information
johnbieren committed Feb 5, 2024
1 parent 81e8d81 commit 17c294a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions utils/translate-delivery-repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
# script: translate-delivery-repo
#
# description: This script translates repo references to the proper public registry reference.
# It turns quay.io/redhat-prod/product----repo into registry.redhat.io/product/repo for production repos and
# quay.io/redhat-pending/product----repo -> registry.stage.redhat.io/product/repo for stage repos.
#
# parameters:
# $0 - The repo to translate. Example: quay.io/redhat-prod/product----repo
#

REPO=$0

if [ -z "${REPO}" ]; then
echo -e "Please pass a repo to translate like 'quay.io/redhat-prod/product----repo'"
exit
fi

if [[ "${REPO}" != "quay.io/redhat-prod"* && "${REPO}" != "quay.io/redhat-pending"* ]] ||
[[ "${REPO}" != *"----"* ]] ; then
echo Malformatted repo to translate. Expected format is quay.io/redhat-[prod,pending]/product----repo
exit 1
fi

REPO=${REPO/quay.io\/redhat-prod/registry.redhat.io}
REPO=${REPO/quay.io\/redhat-pending/registry.stage.redhat.io}
REPO=${REPO//----//}

echo "${REPO}"

0 comments on commit 17c294a

Please sign in to comment.