فهرست منبع

Merge pull request #43530 from thaJeztah/api_cleanup_definitions

api/types: cleanup to use more idiomatic names
Sebastiaan van Stijn 3 سال پیش
والد
کامیت
bf04690bbc
38فایلهای تغییر یافته به همراه163 افزوده شده و 135 حذف شده
  1. 1 1
      api/server/router/container/backend.go
  2. 3 3
      api/server/router/container/container_routes.go
  3. 7 7
      api/server/router/volume/volume_routes.go
  4. 26 23
      api/swagger.yaml
  5. 0 20
      api/types/container/container_create.go
  6. 19 0
      api/types/container/create_response.go
  7. 16 0
      api/types/container/deprecated.go
  8. 3 3
      api/types/container/wait_exit_error.go
  9. 4 4
      api/types/container/wait_response.go
  10. 2 2
      api/types/deprecated.go
  11. 3 3
      api/types/volume/create_options.go
  12. 11 0
      api/types/volume/deprecated.go
  13. 3 3
      api/types/volume/list_response.go
  14. 4 4
      api/types/volume/volume.go
  15. 1 1
      builder/builder.go
  16. 1 1
      builder/dockerfile/containerbackend.go
  17. 6 6
      builder/dockerfile/dispatchers_test.go
  18. 3 3
      builder/dockerfile/mockbackend_test.go
  19. 2 2
      client/container_create.go
  20. 2 2
      client/container_create_test.go
  21. 6 6
      client/container_wait.go
  22. 1 1
      client/container_wait_test.go
  23. 4 4
      client/interface.go
  24. 1 1
      client/volume_create.go
  25. 2 2
      client/volume_create_test.go
  26. 2 2
      client/volume_inspect_test.go
  27. 3 3
      client/volume_list.go
  28. 1 1
      client/volume_list_test.go
  29. 1 1
      daemon/cluster/executor/backend.go
  30. 1 1
      daemon/cluster/executor/container/adapter.go
  31. 4 5
      daemon/cluster/executor/container/container.go
  32. 10 10
      daemon/create.go
  33. 1 1
      hack/generate-swagger-api.sh
  34. 1 1
      integration/internal/container/container.go
  35. 4 4
      integration/plugin/authz/authz_plugin_v2_test.go
  36. 1 1
      integration/system/event_test.go
  37. 2 2
      integration/volume/volume_test.go
  38. 1 1
      volume/service/convert.go

+ 1 - 1
api/server/router/container/backend.go

@@ -32,7 +32,7 @@ type copyBackend interface {
 
 // stateBackend includes functions to implement to provide container state lifecycle functionality.
 type stateBackend interface {
-	ContainerCreate(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
+	ContainerCreate(config types.ContainerCreateConfig) (container.CreateResponse, error)
 	ContainerKill(name string, sig uint64) error
 	ContainerPause(name string) error
 	ContainerRename(oldName, newName string) error

+ 3 - 3
api/server/router/container/container_routes.go

@@ -397,12 +397,12 @@ func (s *containerRouter) postContainersWait(ctx context.Context, w http.Respons
 		return nil
 	}
 
-	var waitError *container.ContainerWaitOKBodyError
+	var waitError *container.WaitExitError
 	if status.Err() != nil {
-		waitError = &container.ContainerWaitOKBodyError{Message: status.Err().Error()}
+		waitError = &container.WaitExitError{Message: status.Err().Error()}
 	}
 
-	return json.NewEncoder(w).Encode(&container.ContainerWaitOKBody{
+	return json.NewEncoder(w).Encode(&container.WaitResponse{
 		StatusCode: int64(status.ExitCode()),
 		Error:      waitError,
 	})

+ 7 - 7
api/server/router/volume/volume_routes.go

@@ -6,7 +6,7 @@ import (
 
 	"github.com/docker/docker/api/server/httputils"
 	"github.com/docker/docker/api/types/filters"
-	volumetypes "github.com/docker/docker/api/types/volume"
+	"github.com/docker/docker/api/types/volume"
 	"github.com/docker/docker/volume/service/opts"
 	"github.com/pkg/errors"
 )
@@ -24,7 +24,7 @@ func (v *volumeRouter) getVolumesList(ctx context.Context, w http.ResponseWriter
 	if err != nil {
 		return err
 	}
-	return httputils.WriteJSON(w, http.StatusOK, &volumetypes.VolumeListOKBody{Volumes: volumes, Warnings: warnings})
+	return httputils.WriteJSON(w, http.StatusOK, &volume.ListResponse{Volumes: volumes, Warnings: warnings})
 }
 
 func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
@@ -32,11 +32,11 @@ func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWrite
 		return err
 	}
 
-	volume, err := v.backend.Get(ctx, vars["name"], opts.WithGetResolveStatus)
+	vol, err := v.backend.Get(ctx, vars["name"], opts.WithGetResolveStatus)
 	if err != nil {
 		return err
 	}
-	return httputils.WriteJSON(w, http.StatusOK, volume)
+	return httputils.WriteJSON(w, http.StatusOK, vol)
 }
 
 func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
@@ -44,16 +44,16 @@ func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWri
 		return err
 	}
 
-	var req volumetypes.VolumeCreateBody
+	var req volume.CreateOptions
 	if err := httputils.ReadJSON(r, &req); err != nil {
 		return err
 	}
 
-	volume, err := v.backend.Create(ctx, req.Name, req.Driver, opts.WithCreateOptions(req.DriverOpts), opts.WithCreateLabels(req.Labels))
+	vol, err := v.backend.Create(ctx, req.Name, req.Driver, opts.WithCreateOptions(req.DriverOpts), opts.WithCreateLabels(req.Labels))
 	if err != nil {
 		return err
 	}
-	return httputils.WriteJSON(w, http.StatusCreated, volume)
+	return httputils.WriteJSON(w, http.StatusCreated, vol)
 }
 
 func (v *volumeRouter) deleteVolumes(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

+ 26 - 23
api/swagger.yaml

@@ -2009,6 +2009,7 @@ definitions:
       UsageData:
         type: "object"
         x-nullable: true
+        x-go-name: "UsageData"
         required: [Size, RefCount]
         description: |
           Usage details about the volume. This information is used by the
@@ -2035,7 +2036,7 @@ definitions:
     description: "Volume configuration"
     type: "object"
     title: "VolumeConfig"
-    x-go-name: "VolumeCreateBody"
+    x-go-name: "CreateOptions"
     properties:
       Name:
         description: |
@@ -2072,7 +2073,7 @@ definitions:
   VolumeListResponse:
     type: "object"
     title: "VolumeListResponse"
-    x-go-name: "VolumeListOKBody"
+    x-go-name: "ListResponse"
     description: "Volume list response"
     properties:
       Volumes:
@@ -4616,10 +4617,30 @@ definitions:
       Health:
         $ref: "#/definitions/Health"
 
+  ContainerCreateResponse:
+    description: "OK response to ContainerCreate operation"
+    type: "object"
+    title: "ContainerCreateResponse"
+    x-go-name: "CreateResponse"
+    required: [Id, Warnings]
+    properties:
+      Id:
+        description: "The ID of the created container"
+        type: "string"
+        x-nullable: false
+        example: "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743"
+      Warnings:
+        description: "Warnings encountered when creating the container"
+        type: "array"
+        x-nullable: false
+        items:
+          type: "string"
+        example: []
+
   ContainerWaitResponse:
     description: "OK response to ContainerWait operation"
     type: "object"
-    x-go-name: "ContainerWaitOKBody"
+    x-go-name: "WaitResponse"
     title: "ContainerWaitResponse"
     required: [StatusCode, Error]
     properties:
@@ -4633,7 +4654,7 @@ definitions:
   ContainerWaitExitError:
     description: "container waiting error, if any"
     type: "object"
-    x-go-name: "ContainerWaitOKBodyError"
+    x-go-name: "WaitExitError"
     properties:
       Message:
         description: "Details of an error"
@@ -6080,25 +6101,7 @@ paths:
         201:
           description: "Container created successfully"
           schema:
-            type: "object"
-            title: "ContainerCreateResponse"
-            description: "OK response to ContainerCreate operation"
-            required: [Id, Warnings]
-            properties:
-              Id:
-                description: "The ID of the created container"
-                type: "string"
-                x-nullable: false
-              Warnings:
-                description: "Warnings encountered when creating the container"
-                type: "array"
-                x-nullable: false
-                items:
-                  type: "string"
-          examples:
-            application/json:
-              Id: "e90e34656806"
-              Warnings: []
+            $ref: "#/definitions/ContainerCreateResponse"
         400:
           description: "bad parameter"
           schema:

+ 0 - 20
api/types/container/container_create.go

@@ -1,20 +0,0 @@
-package container // import "github.com/docker/docker/api/types/container"
-
-// ----------------------------------------------------------------------------
-// Code generated by `swagger generate operation`. DO NOT EDIT.
-//
-// See hack/generate-swagger-api.sh
-// ----------------------------------------------------------------------------
-
-// ContainerCreateCreatedBody OK response to ContainerCreate operation
-// swagger:model ContainerCreateCreatedBody
-type ContainerCreateCreatedBody struct {
-
-	// The ID of the created container
-	// Required: true
-	ID string `json:"Id"`
-
-	// Warnings encountered when creating the container
-	// Required: true
-	Warnings []string `json:"Warnings"`
-}

+ 19 - 0
api/types/container/create_response.go

@@ -0,0 +1,19 @@
+package container
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+// CreateResponse ContainerCreateResponse
+//
+// OK response to ContainerCreate operation
+// swagger:model CreateResponse
+type CreateResponse struct {
+
+	// The ID of the created container
+	// Required: true
+	ID string `json:"Id"`
+
+	// Warnings encountered when creating the container
+	// Required: true
+	Warnings []string `json:"Warnings"`
+}

+ 16 - 0
api/types/container/deprecated.go

@@ -0,0 +1,16 @@
+package container // import "github.com/docker/docker/api/types/container"
+
+// ContainerCreateCreatedBody OK response to ContainerCreate operation
+//
+// Deprecated: use CreateResponse
+type ContainerCreateCreatedBody = CreateResponse
+
+// ContainerWaitOKBody OK response to ContainerWait operation
+//
+// Deprecated: use WaitResponse
+type ContainerWaitOKBody = WaitResponse
+
+// ContainerWaitOKBodyError container waiting error, if any
+//
+// Deprecated: use WaitExitError
+type ContainerWaitOKBodyError = WaitExitError

+ 3 - 3
api/types/container/container_wait_o_k_body_error.go → api/types/container/wait_exit_error.go

@@ -3,9 +3,9 @@ package container
 // This file was generated by the swagger tool.
 // Editing this file might prove futile when you re-run the swagger generate command
 
-// ContainerWaitOKBodyError container waiting error, if any
-// swagger:model ContainerWaitOKBodyError
-type ContainerWaitOKBodyError struct {
+// WaitExitError container waiting error, if any
+// swagger:model WaitExitError
+type WaitExitError struct {
 
 	// Details of an error
 	Message string `json:"Message,omitempty"`

+ 4 - 4
api/types/container/container_wait_o_k_body.go → api/types/container/wait_response.go

@@ -3,15 +3,15 @@ package container
 // This file was generated by the swagger tool.
 // Editing this file might prove futile when you re-run the swagger generate command
 
-// ContainerWaitOKBody ContainerWaitResponse
+// WaitResponse ContainerWaitResponse
 //
 // OK response to ContainerWait operation
-// swagger:model ContainerWaitOKBody
-type ContainerWaitOKBody struct {
+// swagger:model WaitResponse
+type WaitResponse struct {
 
 	// error
 	// Required: true
-	Error *ContainerWaitOKBodyError `json:"Error"`
+	Error *WaitExitError `json:"Error"`
 
 	// Exit code of the container
 	// Required: true

+ 2 - 2
api/types/deprecated.go

@@ -10,5 +10,5 @@ type Volume = volume.Volume
 // VolumeUsageData Usage details about the volume. This information is used by the
 // `GET /system/df` endpoint, and omitted in other endpoints.
 //
-// Deprecated: use github.com/docker/docker/api/types/volume.VolumeUsageData
-type VolumeUsageData = volume.VolumeUsageData
+// Deprecated: use github.com/docker/docker/api/types/volume.UsageData
+type VolumeUsageData = volume.UsageData

+ 3 - 3
api/types/volume/volume_create_body.go → api/types/volume/create_options.go

@@ -3,11 +3,11 @@ package volume
 // This file was generated by the swagger tool.
 // Editing this file might prove futile when you re-run the swagger generate command
 
-// VolumeCreateBody VolumeConfig
+// CreateOptions VolumeConfig
 //
 // Volume configuration
-// swagger:model VolumeCreateBody
-type VolumeCreateBody struct {
+// swagger:model CreateOptions
+type CreateOptions struct {
 
 	// Name of the volume driver to use.
 	Driver string `json:"Driver,omitempty"`

+ 11 - 0
api/types/volume/deprecated.go

@@ -0,0 +1,11 @@
+package volume // import "github.com/docker/docker/api/types/volume"
+
+// VolumeCreateBody Volume configuration
+//
+// Deprecated: use CreateOptions
+type VolumeCreateBody = CreateOptions
+
+// VolumeListOKBody Volume list response
+//
+// Deprecated: use ListResponse
+type VolumeListOKBody = ListResponse

+ 3 - 3
api/types/volume/volume_list_o_k_body.go → api/types/volume/list_response.go

@@ -3,11 +3,11 @@ package volume
 // This file was generated by the swagger tool.
 // Editing this file might prove futile when you re-run the swagger generate command
 
-// VolumeListOKBody VolumeListResponse
+// ListResponse VolumeListResponse
 //
 // Volume list response
-// swagger:model VolumeListOKBody
-type VolumeListOKBody struct {
+// swagger:model ListResponse
+type ListResponse struct {
 
 	// List of volumes
 	Volumes []*Volume `json:"Volumes"`

+ 4 - 4
api/types/volume/volume.go

@@ -47,14 +47,14 @@ type Volume struct {
 	Status map[string]interface{} `json:"Status,omitempty"`
 
 	// usage data
-	UsageData *VolumeUsageData `json:"UsageData,omitempty"`
+	UsageData *UsageData `json:"UsageData,omitempty"`
 }
 
-// VolumeUsageData Usage details about the volume. This information is used by the
+// UsageData Usage details about the volume. This information is used by the
 // `GET /system/df` endpoint, and omitted in other endpoints.
 //
-// swagger:model VolumeUsageData
-type VolumeUsageData struct {
+// swagger:model UsageData
+type UsageData struct {
 
 	// The number of containers referencing this volume. This field
 	// is set to `-1` if the reference-count is not available.

+ 1 - 1
builder/builder.go

@@ -61,7 +61,7 @@ type ExecBackend interface {
 	// ContainerAttachRaw attaches to container.
 	ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool, attached chan struct{}) error
 	// ContainerCreateIgnoreImagesArgsEscaped creates a new Docker container and returns potential warnings
-	ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
+	ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.CreateResponse, error)
 	// ContainerRm removes a container specified by `id`.
 	ContainerRm(name string, config *types.ContainerRmConfig) error
 	// ContainerKill stops the container execution abruptly.

+ 1 - 1
builder/dockerfile/containerbackend.go

@@ -28,7 +28,7 @@ func newContainerManager(docker builder.ExecBackend) *containerManager {
 }
 
 // Create a container
-func (c *containerManager) Create(runConfig *container.Config, hostConfig *container.HostConfig) (container.ContainerCreateCreatedBody, error) {
+func (c *containerManager) Create(runConfig *container.Config, hostConfig *container.HostConfig) (container.CreateResponse, error) {
 	container, err := c.backend.ContainerCreateIgnoreImagesArgsEscaped(types.ContainerCreateConfig{
 		Config:     runConfig,
 		HostConfig: hostConfig,

+ 6 - 6
builder/dockerfile/dispatchers_test.go

@@ -470,12 +470,12 @@ func TestRunWithBuildArgs(t *testing.T) {
 			config: &container.Config{Cmd: origCmd},
 		}, nil, nil
 	}
-	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
+	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.CreateResponse, error) {
 		// Check the runConfig.Cmd sent to create()
 		assert.Check(t, is.DeepEqual(cmdWithShell, config.Config.Cmd))
 		assert.Check(t, is.Contains(config.Config.Env, "one=two"))
 		assert.Check(t, is.DeepEqual(strslice.StrSlice{""}, config.Config.Entrypoint))
-		return container.ContainerCreateCreatedBody{ID: "12345"}, nil
+		return container.CreateResponse{ID: "12345"}, nil
 	}
 	mockBackend.commitFunc = func(cfg backend.CommitConfig) (image.ID, error) {
 		// Check the runConfig.Cmd sent to commit()
@@ -536,8 +536,8 @@ func TestRunIgnoresHealthcheck(t *testing.T) {
 			config: &container.Config{Cmd: origCmd},
 		}, nil, nil
 	}
-	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
-		return container.ContainerCreateCreatedBody{ID: "12345"}, nil
+	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.CreateResponse, error) {
+		return container.CreateResponse{ID: "12345"}, nil
 	}
 	mockBackend.commitFunc = func(cfg backend.CommitConfig) (image.ID, error) {
 		return "", nil
@@ -563,10 +563,10 @@ func TestRunIgnoresHealthcheck(t *testing.T) {
 	assert.NilError(t, dispatch(sb, cmd))
 	assert.Assert(t, sb.state.runConfig.Healthcheck != nil)
 
-	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
+	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.CreateResponse, error) {
 		// Check the Healthcheck is disabled.
 		assert.Check(t, is.DeepEqual([]string{"NONE"}, config.Config.Healthcheck.Test))
-		return container.ContainerCreateCreatedBody{ID: "123456"}, nil
+		return container.CreateResponse{ID: "123456"}, nil
 	}
 
 	sb.state.buildArgs.AddArg("one", strPtr("two"))

+ 3 - 3
builder/dockerfile/mockbackend_test.go

@@ -18,7 +18,7 @@ import (
 
 // MockBackend implements the builder.Backend interface for unit testing
 type MockBackend struct {
-	containerCreateFunc func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
+	containerCreateFunc func(config types.ContainerCreateConfig) (container.CreateResponse, error)
 	commitFunc          func(backend.CommitConfig) (image.ID, error)
 	getImageFunc        func(string) (builder.Image, builder.ROLayer, error)
 	makeImageCacheFunc  func(cacheFrom []string) builder.ImageCache
@@ -28,11 +28,11 @@ func (m *MockBackend) ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout
 	return nil
 }
 
-func (m *MockBackend) ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
+func (m *MockBackend) ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.CreateResponse, error) {
 	if m.containerCreateFunc != nil {
 		return m.containerCreateFunc(config)
 	}
-	return container.ContainerCreateCreatedBody{}, nil
+	return container.CreateResponse{}, nil
 }
 
 func (m *MockBackend) ContainerRm(name string, config *types.ContainerRmConfig) error {

+ 2 - 2
client/container_create.go

@@ -20,8 +20,8 @@ type configWrapper struct {
 
 // ContainerCreate creates a new container based on the given configuration.
 // It can be associated with a name, but it's not mandatory.
-func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error) {
-	var response container.ContainerCreateCreatedBody
+func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error) {
+	var response container.CreateResponse
 
 	if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil {
 		return response, err

+ 2 - 2
client/container_create_test.go

@@ -54,7 +54,7 @@ func TestContainerCreateWithName(t *testing.T) {
 			if name != "container_name" {
 				return nil, fmt.Errorf("container name not set in URL query properly. Expected `container_name`, got %s", name)
 			}
-			b, err := json.Marshal(container.ContainerCreateCreatedBody{
+			b, err := json.Marshal(container.CreateResponse{
 				ID: "container_id",
 			})
 			if err != nil {
@@ -89,7 +89,7 @@ func TestContainerCreateAutoRemove(t *testing.T) {
 			if config.HostConfig.AutoRemove != expectedValue {
 				return nil, fmt.Errorf("expected AutoRemove to be %v, got %v", expectedValue, config.HostConfig.AutoRemove)
 			}
-			b, err := json.Marshal(container.ContainerCreateCreatedBody{
+			b, err := json.Marshal(container.CreateResponse{
 				ID: "container_id",
 			})
 			if err != nil {

+ 6 - 6
client/container_wait.go

@@ -24,12 +24,12 @@ import (
 // wait request or in getting the response. This allows the caller to
 // synchronize ContainerWait with other calls, such as specifying a
 // "next-exit" condition before issuing a ContainerStart request.
-func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) {
+func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) {
 	if versions.LessThan(cli.ClientVersion(), "1.30") {
 		return cli.legacyContainerWait(ctx, containerID)
 	}
 
-	resultC := make(chan container.ContainerWaitOKBody)
+	resultC := make(chan container.WaitResponse)
 	errC := make(chan error, 1)
 
 	query := url.Values{}
@@ -46,7 +46,7 @@ func (cli *Client) ContainerWait(ctx context.Context, containerID string, condit
 
 	go func() {
 		defer ensureReaderClosed(resp)
-		var res container.ContainerWaitOKBody
+		var res container.WaitResponse
 		if err := json.NewDecoder(resp.body).Decode(&res); err != nil {
 			errC <- err
 			return
@@ -60,8 +60,8 @@ func (cli *Client) ContainerWait(ctx context.Context, containerID string, condit
 
 // legacyContainerWait returns immediately and doesn't have an option to wait
 // until the container is removed.
-func (cli *Client) legacyContainerWait(ctx context.Context, containerID string) (<-chan container.ContainerWaitOKBody, <-chan error) {
-	resultC := make(chan container.ContainerWaitOKBody)
+func (cli *Client) legacyContainerWait(ctx context.Context, containerID string) (<-chan container.WaitResponse, <-chan error) {
+	resultC := make(chan container.WaitResponse)
 	errC := make(chan error)
 
 	go func() {
@@ -72,7 +72,7 @@ func (cli *Client) legacyContainerWait(ctx context.Context, containerID string)
 		}
 		defer ensureReaderClosed(resp)
 
-		var res container.ContainerWaitOKBody
+		var res container.WaitResponse
 		if err := json.NewDecoder(resp.body).Decode(&res); err != nil {
 			errC <- err
 			return

+ 1 - 1
client/container_wait_test.go

@@ -38,7 +38,7 @@ func TestContainerWait(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			b, err := json.Marshal(container.ContainerWaitOKBody{
+			b, err := json.Marshal(container.WaitResponse{
 				StatusCode: 15,
 			})
 			if err != nil {

+ 4 - 4
client/interface.go

@@ -47,7 +47,7 @@ type CommonAPIClient interface {
 type ContainerAPIClient interface {
 	ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
 	ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
-	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error)
+	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error)
 	ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
 	ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
 	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
@@ -73,7 +73,7 @@ type ContainerAPIClient interface {
 	ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
 	ContainerUnpause(ctx context.Context, container string) error
 	ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
-	ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error)
+	ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
 	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
 	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
 	ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
@@ -173,10 +173,10 @@ type SystemAPIClient interface {
 
 // VolumeAPIClient defines API client methods for the volumes
 type VolumeAPIClient interface {
-	VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (volume.Volume, error)
+	VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
 	VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)
 	VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
-	VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error)
+	VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error)
 	VolumeRemove(ctx context.Context, volumeID string, force bool) error
 	VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
 }

+ 1 - 1
client/volume_create.go

@@ -8,7 +8,7 @@ import (
 )
 
 // VolumeCreate creates a volume in the docker host.
-func (cli *Client) VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (volume.Volume, error) {
+func (cli *Client) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
 	var vol volume.Volume
 	resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
 	defer ensureReaderClosed(resp)

+ 2 - 2
client/volume_create_test.go

@@ -19,7 +19,7 @@ func TestVolumeCreateError(t *testing.T) {
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
 	}
 
-	_, err := client.VolumeCreate(context.Background(), volume.VolumeCreateBody{})
+	_, err := client.VolumeCreate(context.Background(), volume.CreateOptions{})
 	if !errdefs.IsSystem(err) {
 		t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
 	}
@@ -53,7 +53,7 @@ func TestVolumeCreate(t *testing.T) {
 		}),
 	}
 
-	vol, err := client.VolumeCreate(context.Background(), volume.VolumeCreateBody{
+	vol, err := client.VolumeCreate(context.Background(), volume.CreateOptions{
 		Name:   "myvolume",
 		Driver: "mydriver",
 		DriverOpts: map[string]string{

+ 2 - 2
client/volume_inspect_test.go

@@ -76,7 +76,7 @@ func TestVolumeInspect(t *testing.T) {
 		}),
 	}
 
-	volume, err := client.VolumeInspect(context.Background(), "volume_id")
+	vol, err := client.VolumeInspect(context.Background(), "volume_id")
 	assert.NilError(t, err)
-	assert.Check(t, is.DeepEqual(expected, volume))
+	assert.Check(t, is.DeepEqual(expected, vol))
 }

+ 3 - 3
client/volume_list.go

@@ -6,12 +6,12 @@ import (
 	"net/url"
 
 	"github.com/docker/docker/api/types/filters"
-	volumetypes "github.com/docker/docker/api/types/volume"
+	"github.com/docker/docker/api/types/volume"
 )
 
 // VolumeList returns the volumes configured in the docker host.
-func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) {
-	var volumes volumetypes.VolumeListOKBody
+func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error) {
+	var volumes volume.ListResponse
 	query := url.Values{}
 
 	if filter.Len() > 0 {

+ 1 - 1
client/volume_list_test.go

@@ -69,7 +69,7 @@ func TestVolumeList(t *testing.T) {
 				if actualFilters != listCase.expectedFilters {
 					return nil, fmt.Errorf("filters not set in URL query properly. Expected '%s', got %s", listCase.expectedFilters, actualFilters)
 				}
-				content, err := json.Marshal(volume.VolumeListOKBody{
+				content, err := json.Marshal(volume.ListResponse{
 					Volumes: []*volume.Volume{
 						{
 							Name:   "volume",

+ 1 - 1
daemon/cluster/executor/backend.go

@@ -34,7 +34,7 @@ type Backend interface {
 	FindNetwork(idName string) (libnetwork.Network, error)
 	SetupIngress(clustertypes.NetworkCreateRequest, string) (<-chan struct{}, error)
 	ReleaseIngress() (<-chan struct{}, error)
-	CreateManagedContainer(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
+	CreateManagedContainer(config types.ContainerCreateConfig) (container.CreateResponse, error)
 	ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
 	ContainerStop(ctx context.Context, name string, config container.StopOptions) error
 	ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)

+ 1 - 1
daemon/cluster/executor/container/adapter.go

@@ -283,7 +283,7 @@ func (c *containerAdapter) waitForDetach(ctx context.Context) error {
 }
 
 func (c *containerAdapter) create(ctx context.Context) error {
-	var cr containertypes.ContainerCreateCreatedBody
+	var cr containertypes.CreateResponse
 	var err error
 	if cr, err = c.backend.CreateManagedContainer(types.ContainerCreateConfig{
 		Name:       c.container.name(),

+ 4 - 5
daemon/cluster/executor/container/container.go

@@ -7,8 +7,6 @@ import (
 	"strconv"
 	"strings"
 
-	"github.com/sirupsen/logrus"
-
 	"github.com/docker/distribution/reference"
 	"github.com/docker/docker/api/types"
 	enginecontainer "github.com/docker/docker/api/types/container"
@@ -16,7 +14,7 @@ import (
 	"github.com/docker/docker/api/types/filters"
 	enginemount "github.com/docker/docker/api/types/mount"
 	"github.com/docker/docker/api/types/network"
-	volumetypes "github.com/docker/docker/api/types/volume"
+	"github.com/docker/docker/api/types/volume"
 	"github.com/docker/docker/daemon/cluster/convert"
 	executorpkg "github.com/docker/docker/daemon/cluster/executor"
 	clustertypes "github.com/docker/docker/daemon/cluster/provider"
@@ -28,6 +26,7 @@ import (
 	"github.com/moby/swarmkit/v2/api"
 	"github.com/moby/swarmkit/v2/api/genericresource"
 	"github.com/moby/swarmkit/v2/template"
+	"github.com/sirupsen/logrus"
 )
 
 const (
@@ -406,7 +405,7 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig {
 }
 
 // This handles the case of volumes that are defined inside a service Mount
-func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.VolumeCreateBody {
+func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.CreateOptions {
 	var (
 		driverName string
 		driverOpts map[string]string
@@ -420,7 +419,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.Vol
 	}
 
 	if mount.VolumeOptions != nil {
-		return &volumetypes.VolumeCreateBody{
+		return &volume.CreateOptions{
 			Name:       mount.Source,
 			Driver:     driverName,
 			DriverOpts: driverOpts,

+ 10 - 10
daemon/create.go

@@ -32,7 +32,7 @@ type createOpts struct {
 }
 
 // CreateManagedContainer creates a container that is managed by a Service
-func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig) (containertypes.ContainerCreateCreatedBody, error) {
+func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig) (containertypes.CreateResponse, error) {
 	return daemon.containerCreate(createOpts{
 		params:                  params,
 		managed:                 true,
@@ -40,7 +40,7 @@ func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig)
 }
 
 // ContainerCreate creates a regular container
-func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (containertypes.ContainerCreateCreatedBody, error) {
+func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (containertypes.CreateResponse, error) {
 	return daemon.containerCreate(createOpts{
 		params:                  params,
 		managed:                 false,
@@ -49,22 +49,22 @@ func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (conta
 
 // ContainerCreateIgnoreImagesArgsEscaped creates a regular container. This is called from the builder RUN case
 // and ensures that we do not take the images ArgsEscaped
-func (daemon *Daemon) ContainerCreateIgnoreImagesArgsEscaped(params types.ContainerCreateConfig) (containertypes.ContainerCreateCreatedBody, error) {
+func (daemon *Daemon) ContainerCreateIgnoreImagesArgsEscaped(params types.ContainerCreateConfig) (containertypes.CreateResponse, error) {
 	return daemon.containerCreate(createOpts{
 		params:                  params,
 		managed:                 false,
 		ignoreImagesArgsEscaped: true})
 }
 
-func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.ContainerCreateCreatedBody, error) {
+func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.CreateResponse, error) {
 	start := time.Now()
 	if opts.params.Config == nil {
-		return containertypes.ContainerCreateCreatedBody{}, errdefs.InvalidParameter(errors.New("Config cannot be empty in order to create a container"))
+		return containertypes.CreateResponse{}, errdefs.InvalidParameter(errors.New("Config cannot be empty in order to create a container"))
 	}
 
 	warnings, err := daemon.verifyContainerSettings(opts.params.HostConfig, opts.params.Config, false)
 	if err != nil {
-		return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, errdefs.InvalidParameter(err)
+		return containertypes.CreateResponse{Warnings: warnings}, errdefs.InvalidParameter(err)
 	}
 
 	if opts.params.Platform == nil && opts.params.Config.Image != "" {
@@ -84,7 +84,7 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.Container
 
 	err = verifyNetworkingConfig(opts.params.NetworkingConfig)
 	if err != nil {
-		return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, errdefs.InvalidParameter(err)
+		return containertypes.CreateResponse{Warnings: warnings}, errdefs.InvalidParameter(err)
 	}
 
 	if opts.params.HostConfig == nil {
@@ -92,12 +92,12 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.Container
 	}
 	err = daemon.adaptContainerSettings(opts.params.HostConfig, opts.params.AdjustCPUShares)
 	if err != nil {
-		return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, errdefs.InvalidParameter(err)
+		return containertypes.CreateResponse{Warnings: warnings}, errdefs.InvalidParameter(err)
 	}
 
 	ctr, err := daemon.create(opts)
 	if err != nil {
-		return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err
+		return containertypes.CreateResponse{Warnings: warnings}, err
 	}
 	containerActions.WithValues("create").UpdateSince(start)
 
@@ -105,7 +105,7 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.Container
 		warnings = make([]string, 0) // Create an empty slice to avoid https://github.com/moby/moby/issues/38222
 	}
 
-	return containertypes.ContainerCreateCreatedBody{ID: ctr.ID, Warnings: warnings}, nil
+	return containertypes.CreateResponse{ID: ctr.ID, Warnings: warnings}, nil
 }
 
 // Create creates a new container from the given configuration with a given name.

+ 1 - 1
hack/generate-swagger-api.sh

@@ -18,6 +18,7 @@ swagger generate model -f api/swagger.yaml \
 
 swagger generate model -f api/swagger.yaml \
 	-t api -m types/container --skip-validator -C api/swagger-gen.yaml \
+	-n ContainerCreateResponse \
 	-n ContainerWaitResponse \
 	-n ContainerWaitExitError
 
@@ -32,7 +33,6 @@ swagger generate operation -f api/swagger.yaml \
 	-T api/templates --skip-responses --skip-parameters --skip-validator \
 	-n Authenticate \
 	-n ContainerChanges \
-	-n ContainerCreate \
 	-n ContainerTop \
 	-n ContainerUpdate \
 	-n ImageHistory

+ 1 - 1
integration/internal/container/container.go

@@ -24,7 +24,7 @@ type TestContainerConfig struct {
 }
 
 // create creates a container with the specified options
-func create(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) (container.ContainerCreateCreatedBody, error) {
+func create(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) (container.CreateResponse, error) {
 	t.Helper()
 	cmd := []string{"top"}
 	if runtime.GOOS == "windows" {

+ 4 - 4
integration/plugin/authz/authz_plugin_v2_test.go

@@ -13,7 +13,7 @@ import (
 
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/filters"
-	volumetypes "github.com/docker/docker/api/types/volume"
+	"github.com/docker/docker/api/types/volume"
 	"github.com/docker/docker/client"
 	"github.com/docker/docker/integration/internal/container"
 	"github.com/docker/docker/integration/internal/requirement"
@@ -75,7 +75,7 @@ func TestAuthZPluginV2Disable(t *testing.T) {
 	d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag)
 	d.LoadBusybox(t)
 
-	_, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
+	_, err = c.VolumeCreate(context.Background(), volume.CreateOptions{Driver: "local"})
 	assert.Assert(t, err != nil)
 	assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
 
@@ -84,7 +84,7 @@ func TestAuthZPluginV2Disable(t *testing.T) {
 	assert.NilError(t, err)
 
 	// now test to see if the docker api works.
-	_, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
+	_, err = c.VolumeCreate(context.Background(), volume.CreateOptions{Driver: "local"})
 	assert.NilError(t, err)
 }
 
@@ -101,7 +101,7 @@ func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) {
 	// restart the daemon with the plugin
 	d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag)
 
-	_, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
+	_, err = c.VolumeCreate(context.Background(), volume.CreateOptions{Driver: "local"})
 	assert.Assert(t, err != nil)
 	assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
 

+ 1 - 1
integration/system/event_test.go

@@ -158,7 +158,7 @@ func TestEventsVolumeCreate(t *testing.T) {
 		}
 	}
 
-	_, err := client.VolumeCreate(ctx, volume.VolumeCreateBody{Name: volName})
+	_, err := client.VolumeCreate(ctx, volume.CreateOptions{Name: volName})
 	assert.NilError(t, err)
 
 	filter := filters.NewArgs(

+ 2 - 2
integration/volume/volume_test.go

@@ -28,7 +28,7 @@ func TestVolumesCreateAndList(t *testing.T) {
 	if testEnv.OSType == "windows" {
 		name = strings.ToLower(name)
 	}
-	vol, err := client.VolumeCreate(ctx, volume.VolumeCreateBody{
+	vol, err := client.VolumeCreate(ctx, volume.CreateOptions{
 		Name: name,
 	})
 	assert.NilError(t, err)
@@ -90,7 +90,7 @@ func TestVolumesInspect(t *testing.T) {
 	ctx := context.Background()
 
 	now := time.Now()
-	vol, err := client.VolumeCreate(ctx, volume.VolumeCreateBody{})
+	vol, err := client.VolumeCreate(ctx, volume.CreateOptions{})
 	assert.NilError(t, err)
 
 	inspected, err := client.VolumeInspect(ctx, vol.Name)

+ 1 - 1
volume/service/convert.go

@@ -69,7 +69,7 @@ func (s *VolumesService) volumesToAPI(ctx context.Context, volumes []volume.Volu
 				logrus.WithError(err).WithField("volume", v.Name()).Warnf("Failed to determine size of volume")
 				sz = -1
 			}
-			apiV.UsageData = &volumetypes.VolumeUsageData{Size: sz, RefCount: int64(s.vs.CountReferences(v))}
+			apiV.UsageData = &volumetypes.UsageData{Size: sz, RefCount: int64(s.vs.CountReferences(v))}
 		}
 
 		out = append(out, &apiV)