mirror of
https://github.com/moby/moby.git
synced 2026-08-04 23:21:00 +00:00
api/types/image: InspectResponse: remove deprecated Parent, DockerVersion
The InspectResponse type contains various fields that are deprecated and removed from current API versions, but that were kept for the API server to produce the fields when downgrading to older API versions. - The `Parent` field is only used for the legacy builder, and only set for images that are built locally (i.e., not persisted when pulling an image). - The `DockerVersion` field is only set when building images with the legacy builder, and empty in most cases. Both fields were implicitly deprecated with the deprecation of the legacy builder, and deprecated for the API in [moby@bd8a99b], which was backported to the 28.x release. This patch: - Removes the deprecated fields from the `InspectResposne` struct; this means that [`client.ImageInspect`] won't unmarshal those fields, but the [`docker image inspect`] CLI command defaults to printing the raw output as returned by the API, so can continue to show any field returned in the API response. As a side-note; we should change the CLI to default to show the unmarshalled response, and introduce a `--format=jsonraw` (or `--raw`) option to make printing the raw response opt-in. - Updates the API server to backfill the fields if they are set. [moby@bd8a99b]:bd8a99b400[`client.ImageInspect`]:f739c61c69/client/image_inspect.go (L14-L64)[`docker image inspect`]:74e3520724/cli/command/image/inspect.go (L59-L81)Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -319,10 +319,22 @@ func (s *DockerAPISuite) TestBuildOnBuildCache(c *testing.T) {
|
||||
// check parentID is correct
|
||||
// Parent is graphdriver-only
|
||||
if !testEnv.UsingSnapshotter() {
|
||||
image, err := apiClient.ImageInspect(ctx, childID)
|
||||
var buf bytes.Buffer
|
||||
_, err := apiClient.ImageInspect(ctx, childID, client.ImageInspectWithRawResponse(&buf))
|
||||
assert.NilError(c, err)
|
||||
|
||||
assert.Check(c, is.Equal(parentID, image.Parent)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still included in response when present.
|
||||
var image struct {
|
||||
// Parent is the ID of the parent image.
|
||||
//
|
||||
// Depending on how the image was created, this field may be empty and
|
||||
// is only set for images that were built/created locally. This field
|
||||
// is omitted if the image was pulled from an image registry.
|
||||
Parent string `json:",omitempty"`
|
||||
}
|
||||
rawResponse := buf.Bytes()
|
||||
err = json.Unmarshal(rawResponse, &image)
|
||||
assert.NilError(c, err, string(rawResponse))
|
||||
assert.Check(c, is.Equal(parentID, image.Parent), string(rawResponse))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user