Skip to content

Commit 3afa0cb

Browse files
authored
Remove digest for pushing to local registry but keep it when pulling (#1746)
1 parent 41cd770 commit 3afa0cb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

utils.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,17 @@ function create_cluster() {
153153
cp $ASSET $ASSET_NEW
154154
for IMAGE in $(yq '.. | objects | select(has("containers")) | .containers[].image' $ASSET -r | sort | uniq) ; do
155155
IMAGE_SHORT=${IMAGE##*/}
156+
[[ $IMAGE_SHORT =~ "@" ]] && DIGEST=${IMAGE_SHORT##*@}
157+
# Remove digest from the short name for podman push
158+
IMAGE_SHORT=${IMAGE_SHORT%@*}
156159
IMAGE_MIRRORED=${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}/localimages/assets/${IMAGE_SHORT}
157160
sudo -E podman pull --authfile $PULL_SECRET_FILE $IMAGE
158161
sudo podman push --tls-verify=false --remove-signatures --authfile $PULL_SECRET_FILE $IMAGE $IMAGE_MIRRORED
162+
if [[ -n ${DIGEST:-} ]]; then
163+
# Get digest of the pushed image
164+
DIGEST=$(podman inspect --format "{{.Digest}}" $IMAGE_MIRRORED)
165+
IMAGE_MIRRORED="${IMAGE_MIRRORED}@${DIGEST}"
166+
fi
159167
sed -i -e "s%${IMAGE}%${IMAGE_MIRRORED}%g" $ASSET_NEW
160168
done
161169
done

0 commit comments

Comments
 (0)