Skip to content

Commit bd8a99b

Browse files
committed
api/types/image: InspectResponse: deprecate Parent, DockerVersion
The image inspect response has various fields that were deprecated as part of the legacy builder, or Dockerfile syntax; - 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. This patch deprecates the fields in the `InspectResponse` go struct, as these fields will no longer be set in future once the legacy builder is removed (`Parent`, `DockerVersion`). The legacy builder's deprecation in [cli@4d8e457] / [cli@fd22746] (docker 23.0, API v1.42), however the related API fields were kept so that information of legacy images would not be discarded. The API continues to return these fields if set, allowing the client to print the fields for informational purposes when printing the raw response, but these fields should be considered "transitional", and not be depended on; deprecating the fields helps raise awareness. [cli@4d8e457]: docker/cli@4d8e457 [cli@fd22746]: docker/cli@fd22746 Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f739c61 commit bd8a99b

File tree

10 files changed

+58
-15
lines changed

10 files changed

+58
-15
lines changed

api/docs/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ keywords: "API, Docker, rcli, REST, documentation"
6868
in the next API version.
6969
* Deprecated: The field `KernelMemoryTCP` as part of `GET /info` is deprecated
7070
and will be removed in the next API version.
71+
* Deprecated: the `Parent` and `DockerVersion` fields returned by the
72+
`GET /images/{name}/json` endpoint are deprecated. These fields are set by
73+
the legacy builder, and are no longer set when using BuildKit. The API
74+
continues returning these fields when set for informational purposes, but
75+
they should not be depended on as they will be omitted once the legacy builder
76+
is removed.
7177

7278
## v1.50 API changes
7379

api/docs/v1.51.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,11 @@ definitions:
19381938
Depending on how the image was created, this field may be empty and
19391939
is only set for images that were built/created locally. This field
19401940
is empty if the image was pulled from an image registry.
1941+
1942+
> **Deprecated**: This field is only set when using the deprecated
1943+
> legacy builder. It is included in API responses for informational
1944+
> purposes, but should not be depended on as it will be omitted
1945+
> once the legacy builder is removed.
19411946
type: "string"
19421947
x-nullable: false
19431948
example: ""
@@ -1963,6 +1968,11 @@ definitions:
19631968
The version of Docker that was used to build the image.
19641969
19651970
Depending on how the image was created, this field may be empty.
1971+
1972+
> **Deprecated**: This field is only set when using the deprecated
1973+
> legacy builder. It is included in API responses for informational
1974+
> purposes, but should not be depended on as it will be omitted
1975+
> once the legacy builder is removed.
19661976
type: "string"
19671977
x-nullable: false
19681978
example: "27.0.1"

api/docs/v1.52.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,11 @@ definitions:
18381838
Depending on how the image was created, this field may be empty and
18391839
is only set for images that were built/created locally. This field
18401840
is empty if the image was pulled from an image registry.
1841+
1842+
> **Deprecated**: This field is only set when using the deprecated
1843+
> legacy builder. It is included in API responses for informational
1844+
> purposes, but should not be depended on as it will be omitted
1845+
> once the legacy builder is removed.
18411846
type: "string"
18421847
x-nullable: true
18431848
example: ""
@@ -1863,6 +1868,11 @@ definitions:
18631868
The version of Docker that was used to build the image.
18641869
18651870
Depending on how the image was created, this field may be empty.
1871+
1872+
> **Deprecated**: This field is only set when using the deprecated
1873+
> legacy builder. It is included in API responses for informational
1874+
> purposes, but should not be depended on as it will be omitted
1875+
> once the legacy builder is removed.
18661876
type: "string"
18671877
x-nullable: true
18681878
example: "27.0.1"

api/swagger.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,11 @@ definitions:
18381838
Depending on how the image was created, this field may be empty and
18391839
is only set for images that were built/created locally. This field
18401840
is empty if the image was pulled from an image registry.
1841+
1842+
> **Deprecated**: This field is only set when using the deprecated
1843+
> legacy builder. It is included in API responses for informational
1844+
> purposes, but should not be depended on as it will be omitted
1845+
> once the legacy builder is removed.
18411846
type: "string"
18421847
x-nullable: true
18431848
example: ""
@@ -1863,6 +1868,11 @@ definitions:
18631868
The version of Docker that was used to build the image.
18641869
18651870
Depending on how the image was created, this field may be empty.
1871+
1872+
> **Deprecated**: This field is only set when using the deprecated
1873+
> legacy builder. It is included in API responses for informational
1874+
> purposes, but should not be depended on as it will be omitted
1875+
> once the legacy builder is removed.
18661876
type: "string"
18671877
x-nullable: true
18681878
example: "27.0.1"

api/types/image/image_inspect.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ type InspectResponse struct {
4848
// Depending on how the image was created, this field may be empty and
4949
// is only set for images that were built/created locally. This field
5050
// is omitted if the image was pulled from an image registry.
51+
//
52+
// Deprecated: this field is deprecated, and will be removed in the next release.
5153
Parent string `json:",omitempty"`
5254

5355
// Comment is an optional message that can be set when committing or
@@ -80,6 +82,8 @@ type InspectResponse struct {
8082
// DockerVersion is the version of Docker that was used to build the image.
8183
//
8284
// Depending on how the image was created, this field may be omitted.
85+
//
86+
// Deprecated: this field is deprecated, and will be removed in the next release.
8387
DockerVersion string `json:",omitempty"`
8488

8589
// Author is the name of the author that was specified when committing the

daemon/containerd/image_inspect.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,13 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts ba
8686
}
8787

8888
resp := &imagetypes.InspectResponse{
89-
ID: target.Digest.String(),
90-
RepoTags: repoTags,
91-
Descriptor: &target,
92-
RepoDigests: repoDigests,
93-
Parent: parent,
94-
DockerVersion: "",
95-
Size: size,
96-
Manifests: manifests,
89+
ID: target.Digest.String(),
90+
RepoTags: repoTags,
91+
Descriptor: &target,
92+
RepoDigests: repoDigests,
93+
Parent: parent, //nolint:staticcheck // ignore SA1019: field is deprecated, but still included in response when present.
94+
Size: size,
95+
Manifests: manifests,
9796
Metadata: imagetypes.Metadata{
9897
LastTagTime: lastUpdated,
9998
},

daemon/images/image_inspect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts ba
5858
ID: img.ID().String(),
5959
RepoTags: repoTags,
6060
RepoDigests: repoDigests,
61-
Parent: img.Parent.String(),
61+
Parent: img.Parent.String(), //nolint:staticcheck // ignore SA1019: field is deprecated, but still included in response when present (built with legacy builder).
6262
Comment: comment,
6363
Created: created,
6464
Container: img.Container, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
6565
ContainerConfig: &img.ContainerConfig, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
66-
DockerVersion: img.DockerVersion,
66+
DockerVersion: img.DockerVersion, //nolint:staticcheck // ignore SA1019: field is deprecated, but still included in response when present.
6767
Author: img.Author,
6868
Config: &imgConfig,
6969
Architecture: img.Architecture,

daemon/server/router/image/image_routes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,9 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
421421
// These fields have "omitempty" on API v1.52 and higher,
422422
// but older API versions returned them unconditionally.
423423
legacyOptions = append(legacyOptions, compat.WithExtraFields(map[string]any{
424-
"Parent": imageInspect.Parent,
424+
"Parent": imageInspect.Parent, //nolint:staticcheck // ignore SA1019: field is deprecated, but still included in response when present (built with legacy builder).
425425
"Comment": imageInspect.Comment,
426-
"DockerVersion": imageInspect.DockerVersion,
426+
"DockerVersion": imageInspect.DockerVersion, //nolint:staticcheck // ignore SA1019: field is deprecated, but still included in response when present.
427427
"Author": imageInspect.Author,
428428
}))
429429
if versions.LessThan(version, "1.50") {

integration-cli/docker_api_build_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,16 @@ func (s *DockerAPISuite) TestBuildOnBuildCache(c *testing.T) {
313313
assert.Assert(c, is.Len(imageIDs, 2))
314314
parentID, childID := imageIDs[0], imageIDs[1]
315315

316-
client := testEnv.APIClient()
316+
apiClient := testEnv.APIClient()
317317
ctx := testutil.GetContext(c)
318318

319319
// check parentID is correct
320320
// Parent is graphdriver-only
321321
if !testEnv.UsingSnapshotter() {
322-
image, err := client.ImageInspect(ctx, childID)
322+
image, err := apiClient.ImageInspect(ctx, childID)
323323
assert.NilError(c, err)
324324

325-
assert.Check(c, is.Equal(parentID, image.Parent))
325+
assert.Check(c, is.Equal(parentID, image.Parent)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still included in response when present.
326326
}
327327
}
328328

vendor/github.com/moby/moby/api/types/image/image_inspect.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)