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