diff --git a/api/server/router/container/backend.go b/api/server/router/container/backend.go index 4b495f04f9..e6a5b06b07 100644 --- a/api/server/router/container/backend.go +++ b/api/server/router/container/backend.go @@ -40,7 +40,7 @@ type stateBackend interface { ContainerStart(ctx context.Context, name string, checkpoint string, checkpointDir string) error ContainerStop(ctx context.Context, name string, options container.StopOptions) error ContainerUnpause(name string) error - ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error) + ContainerUpdate(name string, hostConfig *container.HostConfig) (container.UpdateResponse, error) ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error) } diff --git a/api/swagger.yaml b/api/swagger.yaml index 21cdf288cb..707007d3ea 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -5326,6 +5326,21 @@ definitions: type: "string" example: [] + ContainerUpdateResponse: + type: "object" + title: "ContainerUpdateResponse" + x-go-name: "UpdateResponse" + description: |- + Response for a successful container-update. + properties: + Warnings: + type: "array" + description: |- + Warnings encountered when updating the container. + items: + type: "string" + example: ["Published ports are discarded when using host network mode"] + ContainerStatsResponse: description: | Statistics sample for a container. @@ -8560,14 +8575,7 @@ paths: 200: description: "The container has been updated." schema: - type: "object" - title: "ContainerUpdateResponse" - description: "OK response to ContainerUpdate operation" - properties: - Warnings: - type: "array" - items: - type: "string" + $ref: "#/definitions/ContainerUpdateResponse" 404: description: "no such container" schema: diff --git a/api/types/container/container.go b/api/types/container/container.go index 0244a3549a..9642563968 100644 --- a/api/types/container/container.go +++ b/api/types/container/container.go @@ -10,6 +10,11 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) +// ContainerUpdateOKBody OK response to ContainerUpdate operation +// +// Deprecated: use [UpdateResponse]. This alias will be removed in the next release. +type ContainerUpdateOKBody = UpdateResponse + // PruneReport contains the response for Engine API: // POST "/containers/prune" type PruneReport struct { diff --git a/api/types/container/container_update.go b/api/types/container/container_update.go deleted file mode 100644 index c10f175ea8..0000000000 --- a/api/types/container/container_update.go +++ /dev/null @@ -1,16 +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 -// ---------------------------------------------------------------------------- - -// ContainerUpdateOKBody OK response to ContainerUpdate operation -// swagger:model ContainerUpdateOKBody -type ContainerUpdateOKBody struct { - - // warnings - // Required: true - Warnings []string `json:"Warnings"` -} diff --git a/api/types/container/update_response.go b/api/types/container/update_response.go new file mode 100644 index 0000000000..e2b5bf5ac0 --- /dev/null +++ b/api/types/container/update_response.go @@ -0,0 +1,14 @@ +package container + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// UpdateResponse ContainerUpdateResponse +// +// Response for a successful container-update. +// swagger:model UpdateResponse +type UpdateResponse struct { + + // Warnings encountered when updating the container. + Warnings []string `json:"Warnings"` +} diff --git a/client/client_interfaces.go b/client/client_interfaces.go index 719177cbb2..d16991e41b 100644 --- a/client/client_interfaces.go +++ b/client/client_interfaces.go @@ -95,7 +95,7 @@ type ContainerAPIClient interface { ContainerStop(ctx context.Context, container string, options container.StopOptions) error 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) + ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.UpdateResponse, error) ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, container.PathStat, error) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options container.CopyToContainerOptions) error diff --git a/client/container_update.go b/client/container_update.go index d14b14af3c..b9125eef41 100644 --- a/client/container_update.go +++ b/client/container_update.go @@ -8,19 +8,19 @@ import ( ) // ContainerUpdate updates the resources of a container. -func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) { +func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.UpdateResponse, error) { containerID, err := trimID("container", containerID) if err != nil { - return container.ContainerUpdateOKBody{}, err + return container.UpdateResponse{}, err } serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil) defer ensureReaderClosed(serverResp) if err != nil { - return container.ContainerUpdateOKBody{}, err + return container.UpdateResponse{}, err } - var response container.ContainerUpdateOKBody + var response container.UpdateResponse err = json.NewDecoder(serverResp.body).Decode(&response) return response, err } diff --git a/client/container_update_test.go b/client/container_update_test.go index ad9b586e80..772b835201 100644 --- a/client/container_update_test.go +++ b/client/container_update_test.go @@ -41,7 +41,7 @@ func TestContainerUpdate(t *testing.T) { return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL) } - b, err := json.Marshal(container.ContainerUpdateOKBody{}) + b, err := json.Marshal(container.UpdateResponse{}) if err != nil { return nil, err } diff --git a/daemon/update.go b/daemon/update.go index c07b636525..c2d628d8d9 100644 --- a/daemon/update.go +++ b/daemon/update.go @@ -11,20 +11,20 @@ import ( ) // ContainerUpdate updates configuration of the container -func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error) { +func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig) (container.UpdateResponse, error) { var warnings []string daemonCfg := daemon.config() warnings, err := daemon.verifyContainerSettings(daemonCfg, hostConfig, nil, true) if err != nil { - return container.ContainerUpdateOKBody{Warnings: warnings}, errdefs.InvalidParameter(err) + return container.UpdateResponse{Warnings: warnings}, errdefs.InvalidParameter(err) } if err := daemon.update(name, hostConfig); err != nil { - return container.ContainerUpdateOKBody{Warnings: warnings}, err + return container.UpdateResponse{Warnings: warnings}, err } - return container.ContainerUpdateOKBody{Warnings: warnings}, nil + return container.UpdateResponse{Warnings: warnings}, nil } func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) error { diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index 06f9bb3b29..04fb5acedc 100755 --- a/hack/generate-swagger-api.sh +++ b/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 ContainerUpdateResponse \ -n ContainerWaitResponse \ -n ContainerWaitExitError \ -n ChangeType \ @@ -45,7 +46,6 @@ swagger generate operation -f api/swagger.yaml \ -T api/templates --skip-responses --skip-parameters --skip-validator \ -n Authenticate \ -n ContainerTop \ - -n ContainerUpdate \ -n ImageHistory swagger generate model -f api/swagger.yaml \