From b4fbe226e8c21634489fca6ad394096cd6c3c8c5 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Mon, 12 Feb 2024 12:37:23 -0800 Subject: [PATCH 1/2] Set `Created` to `0001-01-01T00:00:00Z` on older API versions This matches the prior behavior before 2a6ff3c24fd790e5d42d2eabaf6acf06edfe6975. This also updates the Swagger documentation for the current version to note that the field might be the empty string and what that means. Signed-off-by: Tianon Gravi --- api/server/router/image/image_routes.go | 6 ++++++ api/swagger.yaml | 2 +- docs/api/v1.44.yaml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go index 4a9f494a3b..d3abee8dd6 100644 --- a/api/server/router/image/image_routes.go +++ b/api/server/router/image/image_routes.go @@ -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) } diff --git a/api/swagger.yaml b/api/swagger.yaml index c1eea71bab..94f4d789dd 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -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" diff --git a/docs/api/v1.44.yaml b/docs/api/v1.44.yaml index e55a76fc63..5e448edad6 100644 --- a/docs/api/v1.44.yaml +++ b/docs/api/v1.44.yaml @@ -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" From 903412d0fcdd818abe6cb46f3eafb24358116e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 14 Feb 2024 10:59:30 +0100 Subject: [PATCH 2/2] api/history: Mention empty `Created` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- docs/api/version-history.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/api/version-history.md b/docs/api/version-history.md index f8279762bf..50ffbb7a40 100644 --- a/docs/api/version-history.md +++ b/docs/api/version-history.md @@ -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