Verify image publication without Python and bind local managed package
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s
Build and Publish Container Image / build-and-push (push) Successful in 58s

Assistant: codex
Assistant-Model: gpt-6-astra
Assistant-Session: 01a140c4-354a-7823-8f0d-8f717397f786
This commit is contained in:
tegwick 2026-10-16 19:52:09 +02:00
parent 0a05383195
commit 84c78e072c
4 changed files with 121 additions and 8 deletions

View file

@ -27,8 +27,22 @@ done
digests=()
for image in "${images[@]}"; do
docker pull "$image:main-$short"
raw=$(docker image inspect --format '{{json .RepoDigests}}' "$image:main-$short")
digest=$(printf '%s' "$raw" | python3 -c 'import json,re,sys; x=json.load(sys.stdin); assert isinstance(x,list); matches=[v.removeprefix(sys.argv[1]+"@") for v in x if isinstance(v,str) and v.startswith(sys.argv[1]+"@")]; assert len(matches)==1 and re.fullmatch(r"sha256:[a-f0-9]{64}",matches[0]); print(matches[0])' "$image")
# The existing container-build runner supplies Bash and Docker, not Python.
# Capture inspect first so command failure is not hidden by process substitution.
raw=$(docker image inspect --format '{{range .RepoDigests}}{{println .}}{{end}}' "$image:main-$short")
digest=""
matches=0
while IFS= read -r reference; do
if [[ "$reference" == "$image@"* ]]; then
candidate=${reference#"$image@"}
[[ "$candidate" =~ ^sha256:[a-f0-9]{64}$ ]] || { echo 'invalid published registry manifest digest' >&2; exit 1; }
digest=$candidate
matches=$((matches + 1))
fi
done <<< "$raw"
[[ "$matches" == 1 ]] || { echo 'expected exactly one published repository digest' >&2; exit 1; }
actual_revision=$(docker image inspect --format '{{index .Config.Labels "org.opencontainers.image.revision"}}' "$image:main-$short")
[[ "$actual_revision" == "$revision" ]] || { echo 'published image revision differs from exact source' >&2; exit 1; }
digests+=("$digest")
done
if [[ "$mode" == paired && "${digests[0]}" != "${digests[1]}" ]]; then