api/types/image: InspectResponse: remove deprecated fields#51103
api/types/image: InspectResponse: remove deprecated fields#51103thaJeztah merged 2 commits intomoby:masterfrom
Conversation
569e9d5 to
e8a8d3d
Compare
| } else { | ||
| if inspectData.Parent != "" { | ||
| // field is deprecated, but still included in response when present (built with legacy builder). | ||
| legacyOptions = append(legacyOptions, compat.WithExtraFields(map[string]any{"Parent": inspectData.Parent})) |
There was a problem hiding this comment.
We should consider adding a WithExtraField option to allow adding a single field; possibly with options like "omitempty / omit zero" for convenience.
Either that or define legacy structs to use, but not sure if that makes things easier.
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. This patch: - Introduces a `imagebackend.InspectData` type for the daemon to use for returning the data needed to propagate the API response. It currently embeds the API response type and combines it with the legacy fields, but this could be changed to return the internal Image type, and mapping the fields to the API response type in the router. - 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. This patch removes the following fields from the `InspectResponse` type; - `VirtualSize`: this field became obsolete with the migration to content- addressable images in docker v1.10 ([moby/moby@4352da7]), but was still returned with a copy of the `Size` field. It was deprecated in API v1.43 ([moby/moby@1261fe6]), and removed in API v1.44 ([moby/moby@913b0f5]). - `Container` and `ContainerConfig`: both fields were deprecated in API v1.44 ([moby/moby@1602e2f]), and removed in API v1.45 ([moby/moby@03cddc6]). remove deprecated Container, ContainerConfig, VirtualSize [moby/moby@4352da7]: moby@4352da7 [moby/moby@1261fe6]: moby@1261fe6 [moby/moby@913b0f5]: moby@913b0f5 [moby/moby@1602e2f]: moby@1602e2f [moby/moby@03cddc6]: moby@03cddc6 [`client.ImageInspect`]: https://github.com/moby/moby/blob/f739c61c69a7155362993c2a2a624e838b3893bc/client/image_inspect.go#L14-L64 [`docker image inspect`]: https://github.com/docker/cli/blob/74e3520724d77e63ef75987cbd0c0cde507ab971/cli/command/image/inspect.go#L59-L81 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…sion 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/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/moby@bd8a99b]: moby@bd8a99b [`client.ImageInspect`]: https://github.com/moby/moby/blob/f739c61c69a7155362993c2a2a624e838b3893bc/client/image_inspect.go#L14-L64 [`docker image inspect`]: https://github.com/docker/cli/blob/74e3520724d77e63ef75987cbd0c0cde507ab971/cli/command/image/inspect.go#L59-L81 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
e8a8d3d to
f8d3c4e
Compare
|
Rebased to get rid of the commits from #51101 - CI was green before this, so I added ☝️ ☝️ ☝️ |
There was a problem hiding this comment.
Pull Request Overview
This PR removes deprecated fields from the api/types/image.InspectResponse type to clean up the Go SDK API while maintaining backward compatibility for older API versions through the server's response handling.
Key changes:
- Introduces
imagebackend.InspectDatatype to hold both current and deprecated fields for internal use - Removes deprecated fields (
VirtualSize,Container,ContainerConfig,Parent,DockerVersion) from the public API type - Updates API server to conditionally include deprecated fields in responses for older API versions
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| api/types/image/image_inspect.go | Removes deprecated fields from InspectResponse struct |
| daemon/server/imagebackend/image.go | Adds new InspectData type containing both current and deprecated fields |
| daemon/images/image_inspect.go | Updates to return InspectData instead of InspectResponse |
| daemon/containerd/image_inspect.go | Updates to return InspectData instead of InspectResponse |
| daemon/server/router/image/image_routes.go | Updates API handler to use InspectData and conditionally include deprecated fields |
| daemon/server/router/image/backend.go | Updates interface signature to return InspectData |
| daemon/image_service.go | Updates interface signature to return InspectData |
| integration-cli/docker_api_build_test.go | Updates test to use raw response parsing for deprecated Parent field |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Let me bring this one in; even CoPilot wasn't able to add nits 😂 |
relates to:
ContainerandContainerConfigfor/images/{id}/json#46939api/types/image: InspectResponse: remove deprecated fields
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.
This patch:
imagebackend.InspectDatatype for the daemon to use forreturning the data needed to propagate the API response. It currently
embeds the API response type and combines it with the legacy fields,
but this could be changed to return the internal Image type, and
mapping the fields to the API response type in the router.
InspectResposnestruct; thismeans that
client.ImageInspectwon't unmarshal those fields, butthe
docker image inspectCLI command defaults to printing the rawoutput 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.This patch removes the following fields from the
InspectResponsetype;VirtualSize: this field became obsolete with the migration to content-addressable images in docker v1.10 (moby@4352da7), but was still returned
with a copy of the
Sizefield. It was deprecated in API v1.43 (moby@1261fe6),and removed in API v1.44 (moby@913b0f5).
ContainerandContainerConfig: both fields were deprecated inAPI v1.44 (moby@1602e2f), and removed in API v1.45 (moby@03cddc6).
remove deprecated Container, ContainerConfig, VirtualSize
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.
Parentfield is only used for the legacy builder, and only set forimages that are built locally (i.e., not persisted when pulling an image).
DockerVersionfield is only set when building images with the legacybuilder, 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:
InspectResposnestruct; thismeans that
client.ImageInspectwon't unmarshal those fields, butthe
docker image inspectCLI command defaults to printing the rawoutput 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.- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)