Skip to content

Commit

Permalink
fix: Handle buildx output with BUILDX_NO_DEFAULT_ATTESTATIONS=1
Browse files Browse the repository at this point in the history
  • Loading branch information
tobni committed Dec 8, 2024
1 parent cd8d262 commit 742ec22
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/python/pants/backend/docker/goals/package_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ def parse_image_id_from_docker_build_output(docker: DockerBinary, *outputs: byte
r"(writing image (?P<digest>sha256:\S+))",
# BuildKit with containerd-snapshotter output.
r"(exporting manifest list (?P<manifest_list>sha256:\S+))",
# BuildKit with containerd-snapshotter output and no attestation.
r"(exporting manifest (?P<manifest>sha256:\S+))",
# Docker output.
r"(Successfully built (?P<short_id>\S+))",
),
Expand All @@ -548,6 +550,7 @@ def parse_image_id_from_docker_build_output(docker: DockerBinary, *outputs: byte
image_id_match.group("digest")
or image_id_match.group("short_id")
or image_id_match.group("manifest_list")
or image_id_match.group("manifest")
)
return image_id

Expand Down
20 changes: 20 additions & 0 deletions src/python/pants/backend/docker/goals/package_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,26 @@ def test_get_context_root(
),
"",
),
# Buildkit with containerd-snapshotter 0.17.1 and disabled attestations
(
DockerBinary("/bin/docker", "1234", is_podman=False),
"sha256:6c3aff6414781126578b3e7b4a217682e89c616c0eac864d5b3ea7c87f1094d0",
dedent(
"""\
#24 exporting to image
#24 exporting layers done
#24 preparing layers for inline cache
#24 preparing layers for inline cache 0.4s done
#24 exporting manifest sha256:6c3aff6414781126578b3e7b4a217682e89c616c0eac864d5b3ea7c87f1094d0 0.0s done
#24 exporting config sha256:af716170542d95134cb41b56e2dfea2c000b05b6fc4f440158ed9834ff96d1b4 0.0s done
#24 naming to REDACTED:latest done
#24 unpacking to REDACTED:latest 0.0s done
#24 DONE 0.5s
"""
),
"",
),
# Podman
(
DockerBinary("/bin/podman", "abcd", is_podman=True),
Expand Down

0 comments on commit 742ec22

Please sign in to comment.