Skip to content

Commit

Permalink
perf: 离线镜像校验
Browse files Browse the repository at this point in the history
  • Loading branch information
wojiushixiaobai committed Dec 29, 2023
1 parent 3487dd2 commit 235498e
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -651,13 +651,42 @@ function pull_image() {
echo ""
}

function check_images() {
images_to=$(get_images)
failed=0

for image in ${images_to}; do
if ! docker image inspect -f '{{ .Id }}' "$image" &> /dev/null; then
pull_image "$image"
fi
done
for image in ${images_to}; do
if ! docker image inspect -f '{{ .Id }}' "$image" &> /dev/null; then
echo_red "$(gettext 'Failed to pull image') ${image}"
failed=1
fi
done

if [ $failed -eq 1 ]; then
exit 1
fi
}

function pull_images() {
images_to=$(get_images)
pids=()

trap 'kill ${pids[*]}' SIGINT SIGTERM

for image in ${images_to}; do
pull_image "$image" &
pids+=($!)
done
wait
wait ${pids[*]}

trap - SIGINT SIGTERM

check_images
}

function installation_log() {
Expand Down

0 comments on commit 235498e

Please sign in to comment.