mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
c8d/image/inspect: Return Descriptor
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -352,6 +352,9 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
|
||||
imageInspect.Container = "" //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
|
||||
imageInspect.ContainerConfig = nil //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
|
||||
}
|
||||
if versions.LessThan(version, "1.48") {
|
||||
imageInspect.Descriptor = nil
|
||||
}
|
||||
return httputils.WriteJSON(w, http.StatusOK, imageInspect)
|
||||
}
|
||||
|
||||
|
||||
@@ -1991,6 +1991,18 @@ definitions:
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
example: "sha256:ec3f0931a6e6b6855d76b2d7b0be30e81860baccd891b2e243280bf1cd8ad710"
|
||||
Descriptor:
|
||||
description: |
|
||||
Descriptor is an OCI descriptor of the image target.
|
||||
In case of a multi-platform image, this descriptor points to the OCI index
|
||||
or a manifest list.
|
||||
|
||||
This field is only present if the daemon provides a multi-platform image store.
|
||||
|
||||
WARNING: This is experimental and may change at any time without any backward
|
||||
compatibility.
|
||||
x-nullable: true
|
||||
$ref: "#/definitions/OCIDescriptor"
|
||||
RepoTags:
|
||||
description: |
|
||||
List of image names/tags in the local image cache that reference this
|
||||
|
||||
@@ -3,6 +3,7 @@ package image
|
||||
import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/storage"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// RootFS returns Image's RootFS description including the layer IDs.
|
||||
@@ -119,4 +120,11 @@ type InspectResponse struct {
|
||||
//
|
||||
// This information is local to the daemon, and not part of the image itself.
|
||||
Metadata Metadata
|
||||
|
||||
// Descriptor is the OCI descriptor of the image target.
|
||||
// It's only set if the daemon provides a multi-platform image store.
|
||||
//
|
||||
// WARNING: This is experimental and may change at any time without any backward
|
||||
// compatibility.
|
||||
Descriptor *ocispec.Descriptor `json:"Descriptor,omitempty"`
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
imgDgst := tagged[0].Target.Digest
|
||||
target := tagged[0].Target
|
||||
|
||||
repoTags := make([]string, 0, len(tagged))
|
||||
repoDigests := make([]string, 0, len(tagged))
|
||||
@@ -78,7 +78,7 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backe
|
||||
continue
|
||||
}
|
||||
|
||||
digested, err := reference.WithDigest(reference.TrimNamed(name), imgDgst)
|
||||
digested, err := reference.WithDigest(reference.TrimNamed(name), target.Digest)
|
||||
if err != nil {
|
||||
// This could only happen if digest is invalid, but considering that
|
||||
// we get it from the Descriptor it's highly unlikely.
|
||||
@@ -107,6 +107,7 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backe
|
||||
return &imagetypes.InspectResponse{
|
||||
ID: img.ImageID(),
|
||||
RepoTags: repoTags,
|
||||
Descriptor: &target,
|
||||
RepoDigests: sliceutil.Dedup(repoDigests),
|
||||
Parent: img.Parent.String(),
|
||||
Comment: comment,
|
||||
|
||||
@@ -34,8 +34,8 @@ keywords: "API, Docker, rcli, REST, documentation"
|
||||
and will be omitted in API v1.49.
|
||||
* `Sysctls` in `HostConfig` (top level `--sysctl` settings) for `eth0` are
|
||||
no longer migrated to `DriverOpts`, as described in the changes for v1.46.
|
||||
* `GET /images/json` response now includes `Descriptor` field, which contains
|
||||
an OCI descriptor of the image target.
|
||||
* `GET /images/json` and `GET /images/{name}/json` responses now include
|
||||
`Descriptor` field, which contains an OCI descriptor of the image target.
|
||||
The new field will only be populated if the daemon provides a multi-platform
|
||||
image store.
|
||||
WARNING: This is experimental and may change at any time without any backward
|
||||
|
||||
@@ -59,3 +59,21 @@ func TestImageInspectUniqueRepoDigests(t *testing.T) {
|
||||
|
||||
assert.Check(t, is.Len(after.RepoDigests, len(before.RepoDigests)))
|
||||
}
|
||||
|
||||
func TestImageInspectDescriptor(t *testing.T) {
|
||||
ctx := setupTest(t)
|
||||
|
||||
client := testEnv.APIClient()
|
||||
|
||||
inspect, _, err := client.ImageInspectWithRaw(ctx, "busybox")
|
||||
assert.NilError(t, err)
|
||||
|
||||
if !testEnv.UsingSnapshotter() {
|
||||
assert.Check(t, inspect.Descriptor == nil)
|
||||
return
|
||||
}
|
||||
|
||||
assert.Assert(t, inspect.Descriptor != nil)
|
||||
assert.Check(t, inspect.Descriptor.Digest.String() == inspect.ID)
|
||||
assert.Check(t, inspect.Descriptor.Size > 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user