@@ -321,11 +321,15 @@ if [ -n "$SSH_KEY" ] && [ ! -f "$SSH_KEY" ]; then
321
321
error " SSH key file not found: $SSH_KEY "
322
322
fi
323
323
324
- parse_image () {
325
- regex=" ^(.*:.*?\/)?(.*\/)?(.*)$"
324
+ extract_image_name_and_tag () {
325
+ local regex=" ^(.*:.*?\/)?(.*\/)?(.*)$"
326
+ local image_name_tag
327
+
326
328
if [[ $IMAGE =~ $regex ]]
327
329
then
328
- IMAGE_NAME_TAG=${BASH_REMATCH[3]}
330
+ image_name_tag=${BASH_REMATCH[3]}
331
+ echo " $image_name_tag "
332
+ return 0
329
333
else
330
334
error " Error parsing reference $IMAGE is not a valid repository/tag: invalid reference format"
331
335
fi
@@ -384,7 +388,7 @@ if is_additional_tunneling_needed; then
384
388
success " Additional tunnel created: localhost:$PUSH_PORT → localhost:$LOCAL_PORT "
385
389
fi
386
390
387
- parse_image
391
+ IMAGE_NAME_TAG= $( extract_image_name_and_tag )
388
392
# Tag and push the image to unregistry through the forwarded port.
389
393
REGISTRY_IMAGE=" localhost:$PUSH_PORT /$IMAGE_NAME_TAG "
390
394
docker tag " $IMAGE " " $REGISTRY_IMAGE "
@@ -407,11 +411,11 @@ if ! ssh "${SSH_ARGS[@]}" "$REMOTE_SUDO docker info -f '{{ .DriverStatus }}' | g
407
411
info " Remote Docker doesn't use containerd image store. Pulling image from unregistry..."
408
412
409
413
REMOTE_REGISTRY_IMAGE=" localhost:$UNREGISTRY_PORT /$IMAGE_NAME_TAG "
410
- if ! ssh " ${SSH_ARGS[@]} " " $REMOTE_SUDO docker pull $remote_registry_image " ; then
414
+ if ! ssh " ${SSH_ARGS[@]} " " $REMOTE_SUDO docker pull $REMOTE_REGISTRY_IMAGE " ; then
411
415
error " Failed to pull image from unregistry on remote host."
412
416
fi
413
417
else
414
- REMOTE_REGISTRY_IMAGE=" $IMAGE_NAME_TAG "
418
+ REMOTE_REGISTRY_IMAGE=" $REGISTRY_IMAGE "
415
419
fi
416
420
417
421
if ! ssh " ${SSH_ARGS[@]} " " $REMOTE_SUDO docker tag $REMOTE_REGISTRY_IMAGE $IMAGE " ; then
0 commit comments