Skip to content

Commit

Permalink
Ensure different tags of images get pushed
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Squizzato <[email protected]>
  • Loading branch information
squizzi committed Nov 4, 2024
1 parent 5741d0f commit 12ff062
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions scripts/airgap-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function print_help() {
echo " -h, --help"
echo " Print this help message"
echo " -r, --image-repo (required)"
echo " The image repo to push the images to, if you do not wish to push the images to a specific repo, set this value to your registry URL"
echo " The image repo to push the images to"
echo " -c, --chart-repo (required)"
echo " The repository to push the Helm charts to, for OCI prefix use oci://"
echo " -a, --airgap-bundle (required)"
Expand Down Expand Up @@ -131,21 +131,29 @@ echo "Retagging and pushing extension images to ${REPO}..."
tar -C ${WORK_DIR} -xf ${WORK_DIR}/${extension_tarball_name} "repositories"
for image in $(cat ${WORK_DIR}/repositories | jq -r 'to_entries[] | .key'); do
image_name=$(echo ${image} | grep -o '[^/]*$')
old_image=$(docker images -a | grep ${image} | awk '{print $1":"$2}')
tag=${old_image#*:}
new_image="${REPO}/${image_name}:${tag}"

docker tag ${old_image} ${new_image}
if [ $? -ne 0 ]; then
echo "Failed to retag image: ${old_image} with ${new_image}"
exit 1
fi
# docker images -a may return multiple images with the same name but
# different tags. We need to retag and push all of them.
for old_image in $(docker images -a | grep ${image} | awk '{print $1":"$2}'); do
tag=${old_image#*:}
new_image="${REPO}/${image_name}:${tag}"

docker push ${new_image}
if [ $? -ne 0 ]; then
echo "Failed to push image: ${new_image}"
exit 1
fi
echo "Retagging image: ${old_image} with ${new_image}..."

docker tag ${old_image} ${new_image}
if [ $? -ne 0 ]; then
echo "Failed to retag image: ${old_image} with ${new_image}"
exit 1
fi

echo "Pushing image: ${new_image}..."

docker push ${new_image}
if [ $? -ne 0 ]; then
echo "Failed to push image: ${new_image}"
exit 1
fi
done
done

# Extract all of the Helm charts from the airgap bundle.
Expand Down

0 comments on commit 12ff062

Please sign in to comment.