Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c8d: Multi-platform image list #47526

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vvoland
Copy link
Contributor

@vvoland vvoland commented Mar 7, 2024

Add the PlatformImages field to ImageSummary.
The original proposal was to enhance ImageSummary with Platform ocispec.Platform and Images []ImageSummary fields, but IMO having a separate type gives us more flexibility.

CLI initial implementation: docker/cli#4982

- How to verify it

$ docker pull busybox
$ docker images --tree
image

- Description for the changelog

- containerd image store: `GET /images/json` response now includes `PlatformImages` field, which contains information about the platform-specific manifests available for the image.
> [!WARNING]  
>
> This is experimental and may change at any time without any backward compatibility.

- A picture of a cute animal (not mandatory but encouraged)
a7c73b012f

@vvoland vvoland added area/api kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny impact/changelog area/images containerd-integration Issues and PRs related to containerd integration labels Mar 7, 2024
@vvoland vvoland added this to the 27.0.0 milestone Mar 7, 2024
@vvoland vvoland self-assigned this Mar 7, 2024
@vvoland vvoland force-pushed the c8d-list-multiplatform branch 2 times, most recently from 9d68e75 to 3507b41 Compare March 7, 2024 19:56
@vvoland vvoland force-pushed the c8d-list-multiplatform branch 4 times, most recently from fc27649 to f7c6a83 Compare April 4, 2024 14:18
@vvoland vvoland changed the title [WIP] c8d: Multi-platform image list c8d: Multi-platform image list Apr 4, 2024
compatibility.
type: "array"
x-nullable: false
x-omitempty: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm CI fails with:

diff --git a/api/types/image/summary.go b/api/types/image/summary.go
index 4ebbdeadf7..fed2746521 100644
--- a/api/types/image/summary.go
+++ b/api/types/image/summary.go
@@ -54,7 +54,7 @@ type Summary struct {
 	// WARNING: This is experimental and may change at any time without any backward
 	// compatibility.
 	//
-	PlatformImages []PlatformImage `json:"PlatformImages,omitempty"`
+	PlatformImages []PlatformImage `json:"PlatformImages"`
 
 	// List of content-addressable digests of locally available image manifests
 	// that the image is referenced from. Multiple manifests can refer to the

Please update api/swagger.yaml with any API changes, then 
run hack/generate-swagger-api.sh.

Even though I marked this one with x-omitempty 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's an issue with the outdated go-swagger, see #47827 for update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled swagger model generation for this struct: 5eb892a

@vvoland vvoland modified the milestones: 26.1.0, 27.0.0 Apr 10, 2024
@vvoland vvoland force-pushed the c8d-list-multiplatform branch 3 times, most recently from 7a67112 to 5eb892a Compare May 14, 2024 12:49
@vvoland
Copy link
Contributor Author

vvoland commented May 15, 2024

// Platform-specific images available for this image.
//
// Only present with the containerd integration enabled.
//
// WARNING: This is experimental and may change at any time without any backward
// compatibility.
//
PlatformImages []PlatformImage `json:"PlatformImages,omitempty"`

Thinking about it a bit more, I think we might want to expose all manifests details, not only the platform-specific images, so we can also provide information about build attestations (and possibly other things in future).

	// Manifests is a list of image manifests available in this image.  It
	// provides a more detailed view of the platform-specific image manifests or
	// other image-attached data like build attestations.
	//
	// WARNING: This is experimental and may change at any time without any backward
	// compatibility.
	//
	Manifests []ImageManifestSummary `json:"Manifests,omitempty"`
type ImageManifestKind string

const (
	ImageManifestKindImage       ImageManifestKind = "image"
	ImageManifestKindAttestation ImageManifestKind = "attestation"
	ImageManifestKindUnknown     ImageManifestKind = "unknown"
)

type ImageManifestSummary struct {
	ID string `json:"Id"`
	Descriptor ocispec.Descriptor `json:"Descriptor"`
	Available bool `json:"Available"`
	ContentSize int64 `json:"ContentSize"`

	Kind ImageManifestKind `json:"Kind"`
	// Fields below are specific to the kind of the image manifest.

	// Present only if Kind == ImageManifestKindImage.
	ImageData ImageProperties `json:"ImageData,omitempty"`

	// Present only if Kind == ImageManifestKindAttestation.
	AttestationData AttestationProperties `json:"AttestationData,omitempty"`
}

type ImageProperties struct {
	Platform ocispec.Platform `json:"Platform"`
	UnpackedSize int64 `json:"UnpackedSize"`
	Containers int64 `json:"Containers"`
}

type AttestationProperties struct {
	// For - the digest of the image manifest that this attestation is for.
	For digest.Digest `json:"For"`
}

This would also leave the gate open for adding any other manifests types in future.

WDYT?

This adds the common helper functions used by the recent
multiplatform-related PRs.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Add the PlatformImages field to `ImageSummary` which describes each
platform-specific manifest in that image.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Our version of go-swagger doesn't handle the `omitempty` correctly for
the new field.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Instead of exposing platform-specific manifests, expose all image
manifests (to also include other blobs using the image media type, like
buildkit attestations).

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api area/images containerd-integration Issues and PRs related to containerd integration impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant