Make toolbox compatible with AR and GCR

Currently, toolbox only pulls images from GCR. To be able to pull
from AR, we regex match on AR host eg.us-central1-docker.pkg.dev
and identify the corresponding registry host. docker-credential-gcr
needs to be run before using toolbox.

BUG=b/267813765
TEST=Tested locally by copying the script to a COS VM.
RELEASE_NOTE=Make toolbox compatible with AR and GCR

Change-Id: Ib2981d081e8efbe74fb0ea59920b7f0cfe19582d
diff --git a/toolbox b/toolbox
index 46fe4e5..efde852 100755
--- a/toolbox
+++ b/toolbox
@@ -58,6 +58,10 @@
 		if [[ "${TOOLBOX_DOCKER_IMAGE}" =~ ^[a-z.]*gcr.io/ ]]; then
 			# Get a host part of the container name
 			registry_host="${TOOLBOX_DOCKER_IMAGE/gcr.io*/gcr.io}"
+		elif [[ "${TOOLBOX_DOCKER_IMAGE}" =~ ^[0-9a-z.-]*docker.pkg.dev/ ]]; then
+			registry_host="${TOOLBOX_DOCKER_IMAGE/docker.pkg.dev*/docker.pkg.dev}"
+		fi
+		if [[ -n "${registry_host}" ]]; then
 			# docker-credential-gcr can fail if it runs in a
 			# non-GCP env, so let it fail and proceed without
 			# --user flag in this case