浏览代码

api/image-inspect: Remove Container and ContainerConfig

Don't include these fields starting from API v1.45.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Paweł Gronowski 1 年之前
父节点
当前提交
03cddc62f4
共有 3 个文件被更改,包括 9 次插入2 次删除
  1. 4 0
      api/server/router/image/image_routes.go
  2. 2 2
      api/types/types.go
  3. 3 0
      docs/api/version-history.md

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

@@ -306,6 +306,10 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
 			imageInspect.Created = time.Time{}.Format(time.RFC3339Nano)
 			imageInspect.Created = time.Time{}.Format(time.RFC3339Nano)
 		}
 		}
 	}
 	}
+	if versions.GreaterThanOrEqualTo(version, "1.45") {
+		imageInspect.Container = ""        //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
+		imageInspect.ContainerConfig = nil //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
+	}
 	return httputils.WriteJSON(w, http.StatusOK, imageInspect)
 	return httputils.WriteJSON(w, http.StatusOK, imageInspect)
 }
 }
 
 

+ 2 - 2
api/types/types.go

@@ -82,7 +82,7 @@ type ImageInspect struct {
 	// Depending on how the image was created, this field may be empty.
 	// Depending on how the image was created, this field may be empty.
 	//
 	//
 	// Deprecated: this field is omitted in API v1.45, but kept for backward compatibility.
 	// Deprecated: this field is omitted in API v1.45, but kept for backward compatibility.
-	Container string
+	Container string `json:",omitempty"`
 
 
 	// ContainerConfig is an optional field containing the configuration of the
 	// ContainerConfig is an optional field containing the configuration of the
 	// container that was last committed when creating the image.
 	// container that was last committed when creating the image.
@@ -91,7 +91,7 @@ type ImageInspect struct {
 	// and it is not in active use anymore.
 	// and it is not in active use anymore.
 	//
 	//
 	// Deprecated: this field is omitted in API v1.45, but kept for backward compatibility.
 	// Deprecated: this field is omitted in API v1.45, but kept for backward compatibility.
-	ContainerConfig *container.Config
+	ContainerConfig *container.Config `json:",omitempty"`
 
 
 	// DockerVersion is the version of Docker that was used to build the image.
 	// DockerVersion is the version of Docker that was used to build the image.
 	//
 	//

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

@@ -22,6 +22,9 @@ keywords: "API, Docker, rcli, REST, documentation"
 * `POST /images/search` will always assume a `false` value for the `is-automated`
 * `POST /images/search` will always assume a `false` value for the `is-automated`
   field. Consequently, searching for `is-automated=true` will yield no results,
   field. Consequently, searching for `is-automated=true` will yield no results,
   while `is-automated=false` will be a no-op.
   while `is-automated=false` will be a no-op.
+* `GET /images/{name}/json` no longer includes the `Container` and
+  `ContainerConfig` fields. To access image configuration, use `Config` field
+  instead.
 
 
 ## v1.44 API changes
 ## v1.44 API changes