mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
Merge pull request #51072 from thaJeztah/image_inspect_omit_legacy
api: omit legacy fields from image inspect if not set
This commit is contained in:
@@ -34,6 +34,12 @@ keywords: "API, Docker, rcli, REST, documentation"
|
||||
* `GET /images/{name}/json` now omits the following `Config` fields when
|
||||
not set, to closer align with the implementation of the [OCI Image Specification](https://github.com/opencontainers/image-spec/blob/v1.1.1/specs-go/v1/config.go#L23-L62)
|
||||
`Cmd`, `Entrypoint`, `Env`, `Labels`, `OnBuild`, `User`, `Volumes`, and `WorkingDir`.
|
||||
* `GET /images/{name}/json` now omits the following fields if their value
|
||||
is empty: `Parent`, `Comment`, `DockerVersion`, `Author`. The `Parent`
|
||||
and `DockerVersion` fields were set by the legacy builder, and are no
|
||||
longer set when using BuildKit. The `Author` field is set through the
|
||||
`MAINTAINER` Dockerfile instruction, which is deprecated, and the `Comment`
|
||||
field is option, and may not be set depending on how the image was created.
|
||||
* `GET /containers/{id}/json`: the `NetworkSettings` no longer returns the deprecated
|
||||
`Bridge`, `HairpinMode`, `LinkLocalIPv6Address`, `LinkLocalIPv6PrefixLen`,
|
||||
`SecondaryIPAddresses`, `SecondaryIPv6Addresses`, `EndpointID`, `Gateway`,
|
||||
|
||||
@@ -1839,13 +1839,13 @@ definitions:
|
||||
is only set for images that were built/created locally. This field
|
||||
is empty if the image was pulled from an image registry.
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
x-nullable: true
|
||||
example: ""
|
||||
Comment:
|
||||
description: |
|
||||
Optional message that was set when committing or importing the image.
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
x-nullable: true
|
||||
example: ""
|
||||
Created:
|
||||
description: |
|
||||
@@ -1864,14 +1864,14 @@ definitions:
|
||||
|
||||
Depending on how the image was created, this field may be empty.
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
x-nullable: true
|
||||
example: "27.0.1"
|
||||
Author:
|
||||
description: |
|
||||
Name of the author that was specified when committing the image, or as
|
||||
specified through MAINTAINER (deprecated) in the Dockerfile.
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
x-nullable: true
|
||||
example: ""
|
||||
Config:
|
||||
$ref: "#/definitions/ImageConfig"
|
||||
|
||||
@@ -1839,13 +1839,13 @@ definitions:
|
||||
is only set for images that were built/created locally. This field
|
||||
is empty if the image was pulled from an image registry.
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
x-nullable: true
|
||||
example: ""
|
||||
Comment:
|
||||
description: |
|
||||
Optional message that was set when committing or importing the image.
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
x-nullable: true
|
||||
example: ""
|
||||
Created:
|
||||
description: |
|
||||
@@ -1864,14 +1864,14 @@ definitions:
|
||||
|
||||
Depending on how the image was created, this field may be empty.
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
x-nullable: true
|
||||
example: "27.0.1"
|
||||
Author:
|
||||
description: |
|
||||
Name of the author that was specified when committing the image, or as
|
||||
specified through MAINTAINER (deprecated) in the Dockerfile.
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
x-nullable: true
|
||||
example: ""
|
||||
Config:
|
||||
$ref: "#/definitions/ImageConfig"
|
||||
|
||||
@@ -47,12 +47,12 @@ type InspectResponse struct {
|
||||
//
|
||||
// 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 empty if the image was pulled from an image registry.
|
||||
Parent string
|
||||
// is omitted if the image was pulled from an image registry.
|
||||
Parent string `json:",omitempty"`
|
||||
|
||||
// Comment is an optional message that can be set when committing or
|
||||
// importing the image.
|
||||
Comment string
|
||||
// importing the image. This field is omitted if not set.
|
||||
Comment string `json:",omitempty"`
|
||||
|
||||
// Created is the date and time at which the image was created, formatted in
|
||||
// RFC 3339 nano-seconds (time.RFC3339Nano).
|
||||
@@ -79,12 +79,13 @@ type InspectResponse struct {
|
||||
|
||||
// DockerVersion is the version of Docker that was used to build the image.
|
||||
//
|
||||
// Depending on how the image was created, this field may be empty.
|
||||
DockerVersion string
|
||||
// Depending on how the image was created, this field may be omitted.
|
||||
DockerVersion string `json:",omitempty"`
|
||||
|
||||
// Author is the name of the author that was specified when committing the
|
||||
// image, or as specified through MAINTAINER (deprecated) in the Dockerfile.
|
||||
Author string
|
||||
// This field is omitted if not set.
|
||||
Author string `json:",omitempty"`
|
||||
Config *dockerspec.DockerOCIImageConfig
|
||||
|
||||
// Architecture is the hardware CPU architecture that the image runs on.
|
||||
|
||||
@@ -418,6 +418,14 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
|
||||
imageInspect.Descriptor = nil
|
||||
}
|
||||
if versions.LessThan(version, "1.52") {
|
||||
// These fields have "omitempty" on API v1.52 and higher,
|
||||
// but older API versions returned them unconditionally.
|
||||
legacyOptions = append(legacyOptions, compat.WithExtraFields(map[string]any{
|
||||
"Parent": imageInspect.Parent,
|
||||
"Comment": imageInspect.Comment,
|
||||
"DockerVersion": imageInspect.DockerVersion,
|
||||
"Author": imageInspect.Author,
|
||||
}))
|
||||
if versions.LessThan(version, "1.50") {
|
||||
legacyOptions = append(legacyOptions, compat.WithExtraFields(legacyConfigFields["v1.49"]))
|
||||
} else {
|
||||
|
||||
15
vendor/github.com/moby/moby/api/types/image/image_inspect.go
generated
vendored
15
vendor/github.com/moby/moby/api/types/image/image_inspect.go
generated
vendored
@@ -47,12 +47,12 @@ type InspectResponse struct {
|
||||
//
|
||||
// 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 empty if the image was pulled from an image registry.
|
||||
Parent string
|
||||
// is omitted if the image was pulled from an image registry.
|
||||
Parent string `json:",omitempty"`
|
||||
|
||||
// Comment is an optional message that can be set when committing or
|
||||
// importing the image.
|
||||
Comment string
|
||||
// importing the image. This field is omitted if not set.
|
||||
Comment string `json:",omitempty"`
|
||||
|
||||
// Created is the date and time at which the image was created, formatted in
|
||||
// RFC 3339 nano-seconds (time.RFC3339Nano).
|
||||
@@ -79,12 +79,13 @@ type InspectResponse struct {
|
||||
|
||||
// DockerVersion is the version of Docker that was used to build the image.
|
||||
//
|
||||
// Depending on how the image was created, this field may be empty.
|
||||
DockerVersion string
|
||||
// Depending on how the image was created, this field may be omitted.
|
||||
DockerVersion string `json:",omitempty"`
|
||||
|
||||
// Author is the name of the author that was specified when committing the
|
||||
// image, or as specified through MAINTAINER (deprecated) in the Dockerfile.
|
||||
Author string
|
||||
// This field is omitted if not set.
|
||||
Author string `json:",omitempty"`
|
||||
Config *dockerspec.DockerOCIImageConfig
|
||||
|
||||
// Architecture is the hardware CPU architecture that the image runs on.
|
||||
|
||||
Reference in New Issue
Block a user