Skip to content

Commit 8e6aa50

Browse files
update test verification script (#485)
update test verification script (#485)
1 parent b08a77c commit 8e6aa50

1 file changed

Lines changed: 66 additions & 8 deletions

File tree

policy/templates/releng/.github/workflows/release.yml.d/goreleaser.gotmpl

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,39 @@
332332
echo "Inspecting layer compression for tag: $TAG"
333333
334334
docker buildx imagetools inspect --raw -- "$TAG" > manifest.json
335-
if grep -q "tar+zstd" manifest.json; then
336-
echo "::error::Image contains zstd-compressed layers! This is incompatible with legacy registries."
337-
cat manifest.json | grep mediaType
338-
exit 1
335+
336+
# Extract child digests (excluding attestation manifests) if it's a multi-arch manifest list / index
337+
DIGESTS=$(jq -r '.manifests[] | select((.platform.architecture // "") != "unknown" and (.annotations["vnd.docker.reference.type"] // "") != "attestation-manifest") | .digest' manifest.json 2>/dev/null || true)
338+
339+
verify_manifest() {
340+
local file=$1
341+
# Check if any layer does NOT end in gzip/tar+gzip/tar.gzip
342+
local invalid_layers
343+
invalid_layers=$(jq -r '.layers[].mediaType' "$file" | grep -v 'tar+gzip' | grep -v 'tar.gzip' || true)
344+
if [ -n "$invalid_layers" ]; then
345+
echo "::error::Found layers that are not gzip-compressed:"
346+
echo "$invalid_layers"
347+
exit 1
348+
fi
349+
# Also verify we found at least one layer
350+
local layer_count
351+
layer_count=$(jq '.layers | length' "$file" 2>/dev/null || echo 0)
352+
if [ "$layer_count" -eq 0 ]; then
353+
echo "::error::No layers found in manifest!"
354+
exit 1
355+
fi
356+
}
357+
358+
if [ -n "$DIGESTS" ]; then
359+
echo "Multi-arch image list detected. Checking each platform manifest..."
360+
for digest in $DIGESTS; do
361+
echo "Inspecting child platform manifest: $digest"
362+
docker buildx imagetools inspect --raw -- "$TAG@$digest" > child_manifest.json
363+
verify_manifest child_manifest.json
364+
done
365+
else
366+
echo "Single-arch manifest detected. Checking manifest..."
367+
verify_manifest manifest.json
339368
fi
340369
echo "Success: All layers are uniformly compressed using gzip."
341370
@@ -391,10 +420,39 @@
391420
echo "Inspecting layer compression for tag: $TAG"
392421
393422
docker buildx imagetools inspect --raw -- "$TAG" > manifest.json
394-
if grep -q "tar+zstd" manifest.json; then
395-
echo "::error::Image contains zstd-compressed layers! This is incompatible with legacy registries."
396-
cat manifest.json | grep mediaType
397-
exit 1
423+
424+
# Extract child digests (excluding attestation manifests) if it's a multi-arch manifest list / index
425+
DIGESTS=$(jq -r '.manifests[] | select((.platform.architecture // "") != "unknown" and (.annotations["vnd.docker.reference.type"] // "") != "attestation-manifest") | .digest' manifest.json 2>/dev/null || true)
426+
427+
verify_manifest() {
428+
local file=$1
429+
# Check if any layer does NOT end in gzip/tar+gzip/tar.gzip
430+
local invalid_layers
431+
invalid_layers=$(jq -r '.layers[].mediaType' "$file" | grep -v 'tar+gzip' | grep -v 'tar.gzip' || true)
432+
if [ -n "$invalid_layers" ]; then
433+
echo "::error::Found layers that are not gzip-compressed:"
434+
echo "$invalid_layers"
435+
exit 1
436+
fi
437+
# Also verify we found at least one layer
438+
local layer_count
439+
layer_count=$(jq '.layers | length' "$file" 2>/dev/null || echo 0)
440+
if [ "$layer_count" -eq 0 ]; then
441+
echo "::error::No layers found in manifest!"
442+
exit 1
443+
fi
444+
}
445+
446+
if [ -n "$DIGESTS" ]; then
447+
echo "Multi-arch image list detected. Checking each platform manifest..."
448+
for digest in $DIGESTS; do
449+
echo "Inspecting child platform manifest: $digest"
450+
docker buildx imagetools inspect --raw -- "$TAG@$digest" > child_manifest.json
451+
verify_manifest child_manifest.json
452+
done
453+
else
454+
echo "Single-arch manifest detected. Checking manifest..."
455+
verify_manifest manifest.json
398456
fi
399457
echo "Success: All layers are uniformly compressed using gzip."
400458
{{- if and $bv.DockerBaseImage (ne $bv.DockerBaseImage "distroless") }}

0 commit comments

Comments
 (0)