Added error check.

Added error check so that instead of breaking, if containers cant be checked on the registry (eg. locally built or deprecated) they'll be added to a error-list.
This commit is contained in:
mag37
2023-01-20 12:47:17 +01:00
committed by GitHub
parent d5afc8f402
commit 8f95ac0305

View File

@ -63,11 +63,16 @@ do
printf ". " printf ". "
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}') RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}' | sed -e 's/.*sha256/sha256/' -e 's/\]$//') LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}' | sed -e 's/.*sha256/sha256/' -e 's/\]$//')
RegHash=$($regbin image digest --list "$RepoUrl") RegHash=$($regbin image digest --list "$RepoUrl" 2>/dev/null)
if [[ "$LocalHash" != "$RegHash" ]] ; then # Check if regtcl produces errors - add to GotErrors if so.
GotUpdates+=("$i") if [ $? -eq 0 ] ; then
if [[ "$LocalHash" != "$RegHash" ]] ; then
GotUpdates+=("$i")
else
NoUpdates+=("$i")
fi
else else
NoUpdates+=("$i") GotErrors+=("$i")
fi fi
done done
@ -80,6 +85,10 @@ if [ -n "$GotUpdates" ] ; then
printf "\n\033[31;1mContainers with updates available:\033[0m\n" printf "\n\033[31;1mContainers with updates available:\033[0m\n"
printf "%s\n" "${GotUpdates[@]}" printf "%s\n" "${GotUpdates[@]}"
fi fi
if [ -n "$GotErrors" ] ; then
printf "\n\033[33;1mContainers with errors, wont get updated:\033[0m\n"
printf "%s\n" "${GotErrors[@]}"
fi
### Optionally get updates if there's any ### Optionally get updates if there's any
if [ -n "$GotUpdates" ] ; then if [ -n "$GotUpdates" ] ; then