Support retry
This commit is contained in:
parent
aa87ccda1b
commit
3026887aca
|
@ -31,6 +31,9 @@ PARALLET="${PARALLET:-0}"
|
||||||
# Synchronize images from source to destination
|
# Synchronize images from source to destination
|
||||||
SYNC="${SYNC:-}"
|
SYNC="${SYNC:-}"
|
||||||
|
|
||||||
|
# Retry times
|
||||||
|
RETRY="${RETRY:-5}"
|
||||||
|
|
||||||
SELF="$(basename "${BASH_SOURCE[0]}")"
|
SELF="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
if [[ "${DEBUG}" == "true" ]]; then
|
if [[ "${DEBUG}" == "true" ]]; then
|
||||||
|
@ -45,6 +48,7 @@ if [[ "${DEBUG}" == "true" ]]; then
|
||||||
echo "SKIP: ${SKIP}"
|
echo "SKIP: ${SKIP}"
|
||||||
echo "PARALLET: ${PARALLET}"
|
echo "PARALLET: ${PARALLET}"
|
||||||
echo "SYNC: ${SYNC}"
|
echo "SYNC: ${SYNC}"
|
||||||
|
echo "RETRY: ${RETRY}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function check() {
|
function check() {
|
||||||
|
@ -65,6 +69,7 @@ function check() {
|
||||||
echo " SKIP=<pattern> # Regexp that matches the tags that needs to be skipped"
|
echo " SKIP=<pattern> # Regexp that matches the tags that needs to be skipped"
|
||||||
echo " PARALLET=<size> # Compare the number of tags in parallel"
|
echo " PARALLET=<size> # Compare the number of tags in parallel"
|
||||||
echo " SYNC=true # Synchronize images from source to destination"
|
echo " SYNC=true # Synchronize images from source to destination"
|
||||||
|
echo " RETRY=<times> # Retry times"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -89,9 +94,9 @@ emptyLayer="sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b4
|
||||||
|
|
||||||
function inspect() {
|
function inspect() {
|
||||||
local image="${1:-}"
|
local image="${1:-}"
|
||||||
local raw=$(${SKOPEO} inspect --no-creds --raw --tls-verify=false "docker://${image}")
|
local raw=$(${SKOPEO} inspect --retry-times "${RETRY}" --no-creds --raw --tls-verify=false "docker://${image}")
|
||||||
if [[ "${raw}" == "" ]]; then
|
if [[ "${raw}" == "" ]]; then
|
||||||
echo "skopeo inspect --no-creds --raw --tls-verify=false docker://${image}" >&2
|
echo "skopeo inspect --retry-times "${RETRY}" --no-creds --raw --tls-verify=false docker://${image}" >&2
|
||||||
echo "ERROR: Failed to inspect ${image}" >&2
|
echo "ERROR: Failed to inspect ${image}" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -122,12 +127,12 @@ function inspect() {
|
||||||
local arch="${args%% *}"
|
local arch="${args%% *}"
|
||||||
local os="${args##* }"
|
local os="${args##* }"
|
||||||
echo ${args}
|
echo ${args}
|
||||||
${SKOPEO} --override-arch "${arch}" --override-os "${os}" inspect --no-creds --config --tls-verify=false "docker://${image}" | jq -r '.rootfs.diff_ids[]'
|
${SKOPEO} --override-arch "${arch}" --override-os "${os}" inspect --retry-times "${RETRY}" --no-creds --config --tls-verify=false "docker://${image}" | jq -r '.rootfs.diff_ids[]'
|
||||||
done
|
done
|
||||||
unset IFS
|
unset IFS
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "skopeo inspect --no-creds --raw --tls-verify=false docker://${image}" >&2
|
echo "skopeo inspect --retry-times "${RETRY}" --no-creds --raw --tls-verify=false docker://${image}" >&2
|
||||||
if [[ "${DEBUG}" == "true" ]]; then
|
if [[ "${DEBUG}" == "true" ]]; then
|
||||||
echo "${raw}" >&2
|
echo "${raw}" >&2
|
||||||
fi
|
fi
|
||||||
|
@ -137,7 +142,7 @@ function inspect() {
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "skopeo inspect --no-creds --raw --tls-verify=false docker://${image}" >&2
|
echo "skopeo inspect --retry-times "${RETRY}" --no-creds --raw --tls-verify=false docker://${image}" >&2
|
||||||
if [[ "${DEBUG}" == "true" ]]; then
|
if [[ "${DEBUG}" == "true" ]]; then
|
||||||
echo "${raw}" >&2
|
echo "${raw}" >&2
|
||||||
fi
|
fi
|
||||||
|
@ -151,12 +156,12 @@ function copy-image() {
|
||||||
local image1="${1:-}"
|
local image1="${1:-}"
|
||||||
local image2="${2:-}"
|
local image2="${2:-}"
|
||||||
|
|
||||||
${SKOPEO} copy --all --src-no-creds --dest-tls-verify=false --format oci "docker://${image1}" "docker://${image2}"
|
${SKOPEO} copy --retry-times "${RETRY}" --all --src-no-creds --dest-tls-verify=false --format oci "docker://${image1}" "docker://${image2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function list-tags() {
|
function list-tags() {
|
||||||
local image="${1:-}"
|
local image="${1:-}"
|
||||||
local raw="$(${SKOPEO} list-tags --no-creds --tls-verify=false "docker://${image}" | ${JQ} -r '.Tags[]' | sort)"
|
local raw="$(${SKOPEO} list-tags --retry-times "${RETRY}" --no-creds --tls-verify=false "docker://${image}" | ${JQ} -r '.Tags[]' | sort)"
|
||||||
|
|
||||||
if [[ "${FOCUS}" != "" ]]; then
|
if [[ "${FOCUS}" != "" ]]; then
|
||||||
local skip=$(echo "${raw}" | grep -v -E "${FOCUS}")
|
local skip=$(echo "${raw}" | grep -v -E "${FOCUS}")
|
||||||
|
|
Loading…
Reference in New Issue