Skip to content

Commit b4fbe22

Browse files
committed
Set Created to 0001-01-01T00:00:00Z on older API versions
This matches the prior behavior before 2a6ff3c. 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 <[email protected]>
1 parent a60546b commit b4fbe22

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

api/server/router/image/image_routes.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
299299
version := httputils.VersionFromContext(ctx)
300300
if versions.LessThan(version, "1.44") {
301301
imageInspect.VirtualSize = imageInspect.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
302+
303+
if imageInspect.Created == "" {
304+
// backwards compatibility for Created not existing returning "0001-01-01T00:00:00Z"
305+
// https://github.com/moby/moby/issues/47368
306+
imageInspect.Created = time.Time{}.Format(time.RFC3339Nano)
307+
}
302308
}
303309
return httputils.WriteJSON(w, http.StatusOK, imageInspect)
304310
}

api/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ definitions:
17461746
Created:
17471747
description: |
17481748
Date and time at which the image was created, formatted in
1749-
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.
1749+
[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.
17501750
type: "string"
17511751
x-nullable: false
17521752
example: "2022-02-04T21:20:12.497794809Z"

docs/api/v1.44.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ definitions:
17421742
Created:
17431743
description: |
17441744
Date and time at which the image was created, formatted in
1745-
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.
1745+
[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.
17461746
type: "string"
17471747
x-nullable: false
17481748
example: "2022-02-04T21:20:12.497794809Z"

0 commit comments

Comments
 (0)