Skip to content

Commit

Permalink
Merge pull request moby#47374 from tianon/api-inspect-created
Browse files Browse the repository at this point in the history
Set `Created` to `0001-01-01T00:00:00Z` on older API versions
  • Loading branch information
thaJeztah authored Feb 14, 2024
2 parents 3d35459 + 903412d commit a0f12f9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions api/server/router/image/image_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
version := httputils.VersionFromContext(ctx)
if versions.LessThan(version, "1.44") {
imageInspect.VirtualSize = imageInspect.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.

if imageInspect.Created == "" {
// backwards compatibility for Created not existing returning "0001-01-01T00:00:00Z"
// https://github.com/moby/moby/issues/47368
imageInspect.Created = time.Time{}.Format(time.RFC3339Nano)
}
}
return httputils.WriteJSON(w, http.StatusOK, imageInspect)
}
Expand Down
2 changes: 1 addition & 1 deletion api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ definitions:
Created:
description: |
Date and time at which the image was created, formatted in
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds, or empty if the field was not set in the image config.
type: "string"
x-nullable: false
example: "2022-02-04T21:20:12.497794809Z"
Expand Down
2 changes: 1 addition & 1 deletion docs/api/v1.44.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@ definitions:
Created:
description: |
Date and time at which the image was created, formatted in
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds, or empty if the field was not set in the image config.
type: "string"
x-nullable: false
example: "2022-02-04T21:20:12.497794809Z"
Expand Down
3 changes: 3 additions & 0 deletions docs/api/version-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ keywords: "API, Docker, rcli, REST, documentation"
`SecondaryIPv6Addresses` available in `NetworkSettings` when calling `GET /containers/{id}/json` are
deprecated and will be removed in a future release. You should instead look for the default network in
`NetworkSettings.Networks`.
* `GET /images/{id}/json` now responds with an empty `Created` field
(previously it was `0001-01-01T00:00:00Z`) if the `Created` field is missing
from the image config.

## v1.43 API changes

Expand Down

0 comments on commit a0f12f9

Please sign in to comment.