Skip to content

Commit 144b033

Browse files
author
Jonathan Mabit
committed
fixes from review
1 parent 9c8588e commit 144b033

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

docker-pussh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,15 @@ if [ -n "$SSH_KEY" ] && [ ! -f "$SSH_KEY" ]; then
321321
error "SSH key file not found: $SSH_KEY"
322322
fi
323323

324-
parse_image() {
325-
regex="^(.*:.*?\/)?(.*\/)?(.*)$"
324+
extract_image_name_and_tag() {
325+
local regex="^(.*:.*?\/)?(.*\/)?(.*)$"
326+
local image_name_tag
327+
326328
if [[ $IMAGE =~ $regex ]]
327329
then
328-
IMAGE_NAME_TAG=${BASH_REMATCH[3]}
330+
image_name_tag=${BASH_REMATCH[3]}
331+
echo "$image_name_tag"
332+
return 0
329333
else
330334
error "Error parsing reference $IMAGE is not a valid repository/tag: invalid reference format"
331335
fi
@@ -384,7 +388,7 @@ if is_additional_tunneling_needed; then
384388
success "Additional tunnel created: localhost:$PUSH_PORT → localhost:$LOCAL_PORT"
385389
fi
386390

387-
parse_image
391+
IMAGE_NAME_TAG=$(extract_image_name_and_tag)
388392
# Tag and push the image to unregistry through the forwarded port.
389393
REGISTRY_IMAGE="localhost:$PUSH_PORT/$IMAGE_NAME_TAG"
390394
docker tag "$IMAGE" "$REGISTRY_IMAGE"
@@ -407,11 +411,11 @@ if ! ssh "${SSH_ARGS[@]}" "$REMOTE_SUDO docker info -f '{{ .DriverStatus }}' | g
407411
info "Remote Docker doesn't use containerd image store. Pulling image from unregistry..."
408412

409413
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
411415
error "Failed to pull image from unregistry on remote host."
412416
fi
413417
else
414-
REMOTE_REGISTRY_IMAGE="$IMAGE_NAME_TAG"
418+
REMOTE_REGISTRY_IMAGE="$REGISTRY_IMAGE"
415419
fi
416420

417421
if ! ssh "${SSH_ARGS[@]}" "$REMOTE_SUDO docker tag $REMOTE_REGISTRY_IMAGE $IMAGE"; then

0 commit comments

Comments
 (0)