mirror of
https://github.com/DaoCloud/public-image-mirror.git
synced 2025-08-08 05:32:41 +08:00
Update check image
This commit is contained in:
32
hack/correct-image.sh
Executable file
32
hack/correct-image.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function guess_image() {
|
||||
local image="${1}"
|
||||
|
||||
image="${image# }"
|
||||
image="${image% }"
|
||||
|
||||
if [[ -z "${image}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${image}" == *"registry.docker.com/r"* ]]; then
|
||||
image="docker.io/${image##*registry.hub.docker.com\/r\/}"
|
||||
fi
|
||||
if [[ "${image}" == *"hub.docker.com/r"* ]]; then
|
||||
image="docker.io/${image##*hub.docker.com\/r\/}"
|
||||
fi
|
||||
if [[ "${image%%/*}" != *"."* ]] || [[ "${image}" != *"/"* ]]; then
|
||||
image="docker.io/${image}"
|
||||
fi
|
||||
if [[ "${image}" != *":"* ]]; then
|
||||
image="${image}:latest"
|
||||
fi
|
||||
if [[ "${image}" == *"//"* ]] || [[ "${image}" == *" "* ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo "${image}"
|
||||
}
|
||||
|
||||
guess_image "${1}"
|
Reference in New Issue
Block a user