Skip to content

api/types/image: InspectResponse: remove deprecated fields#51103

Merged
thaJeztah merged 2 commits intomoby:masterfrom
thaJeztah:image_inspect_rm_deprecated
Oct 8, 2025
Merged

api/types/image: InspectResponse: remove deprecated fields#51103
thaJeztah merged 2 commits intomoby:masterfrom
thaJeztah:image_inspect_rm_deprecated

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Oct 5, 2025

relates to:

api/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:

  • 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@4352da7), but was still returned
    with a copy of the Size field. It was deprecated in API v1.43 (moby@1261fe6),
    and removed in API v1.44 (moby@913b0f5).
  • Container and ContainerConfig: both fields were deprecated in
    API 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.

  • 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.

- Human readable description for the release notes

Go SDK: api/types/image: `InspectResponse`: remove deprecated `VirtualSize`, `Container`, `ContainerConfig`, `Parent`, and `DockerVersion` fields.

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

@thaJeztah thaJeztah added area/api API status/2-code-review impact/changelog impact/deprecation kind/refactor PR's that refactor, or clean-up code area/go-sdk impact/go-sdk Noteworthy (compatibility changes) in the Go SDK release-blocker PRs we want to block a release on module/api labels Oct 5, 2025
@thaJeztah thaJeztah added this to the 29.0.0 milestone Oct 5, 2025
@thaJeztah thaJeztah force-pushed the image_inspect_rm_deprecated branch 5 times, most recently from 569e9d5 to e8a8d3d Compare October 7, 2025 07:16
} 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}))
Copy link
Member Author

Choose a reason for hiding this comment

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

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>
@thaJeztah thaJeztah force-pushed the image_inspect_rm_deprecated branch from e8a8d3d to f8d3c4e Compare October 7, 2025 11:31
@thaJeztah
Copy link
Member Author

Rebased to get rid of the commits from #51101 - CI was green before this, so I added validate-only

☝️ ☝️ ☝️

@thaJeztah thaJeztah marked this pull request as ready for review October 7, 2025 11:32
@austinvazquez austinvazquez requested a review from Copilot October 7, 2025 13:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.InspectData type 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.

@thaJeztah
Copy link
Member Author

Let me bring this one in; even CoPilot wasn't able to add nits 😂

@thaJeztah thaJeztah merged commit 77ca284 into moby:master Oct 8, 2025
54 checks passed
@thaJeztah thaJeztah deleted the image_inspect_rm_deprecated branch October 8, 2025 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API area/go-sdk ci/validate-only impact/changelog impact/deprecation impact/go-sdk Noteworthy (compatibility changes) in the Go SDK kind/refactor PR's that refactor, or clean-up code module/api release-blocker PRs we want to block a release on status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants