api/types/container: rename ContainerUpdateOKBody to UpdateResponse

Deprecate ContainerUpdateOKBody, but keep an alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-02-10 18:30:31 +01:00
parent 7adac77d6b
commit f4dc38cd36
10 changed files with 47 additions and 36 deletions

View File

@@ -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)
}

View File

@@ -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:

View File

@@ -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 {

View File

@@ -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"`
}

View File

@@ -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"`
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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 \