Selaa lähdekoodia

Merge pull request #47387 from neersighted/backport/47374/25.0

[25.0 backport] Set `Created` to `0001-01-01T00:00:00Z` on older API versions
Bjorn Neergaard 1 vuosi sitten
vanhempi
commit
36d02bf488

+ 6 - 0
api/server/router/image/image_routes.go

@@ -298,6 +298,12 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
 	version := httputils.VersionFromContext(ctx)
 	version := httputils.VersionFromContext(ctx)
 	if versions.LessThan(version, "1.44") {
 	if versions.LessThan(version, "1.44") {
 		imageInspect.VirtualSize = imageInspect.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.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)
 	return httputils.WriteJSON(w, http.StatusOK, imageInspect)
 }
 }

+ 1 - 1
api/swagger.yaml

@@ -1742,7 +1742,7 @@ definitions:
       Created:
       Created:
         description: |
         description: |
           Date and time at which the image was created, formatted in
           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"
         type: "string"
         x-nullable: false
         x-nullable: false
         example: "2022-02-04T21:20:12.497794809Z"
         example: "2022-02-04T21:20:12.497794809Z"

+ 1 - 1
docs/api/v1.44.yaml

@@ -1742,7 +1742,7 @@ definitions:
       Created:
       Created:
         description: |
         description: |
           Date and time at which the image was created, formatted in
           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"
         type: "string"
         x-nullable: false
         x-nullable: false
         example: "2022-02-04T21:20:12.497794809Z"
         example: "2022-02-04T21:20:12.497794809Z"

+ 3 - 0
docs/api/version-history.md

@@ -79,6 +79,9 @@ keywords: "API, Docker, rcli, REST, documentation"
   `SecondaryIPv6Addresses` available in `NetworkSettings` when calling `GET /containers/{id}/json` are
   `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
   deprecated and will be removed in a future release. You should instead look for the default network in
   `NetworkSettings.Networks`.
   `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
 ## v1.43 API changes