Generate container update response from swagger spec.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-10-18 17:35:45 -07:00
parent c8d5e7203e
commit f196cf6a09
9 changed files with 32 additions and 26 deletions

View File

@ -42,7 +42,7 @@ type stateBackend interface {
ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool, checkpoint string, checkpointDir string) error
ContainerStop(name string, seconds *int) error
ContainerUnpause(name string) error
ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (types.ContainerUpdateResponse, error)
ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (container.ContainerUpdateOKBody, error)
ContainerWait(name string, timeout time.Duration) (int, error)
}

View File

@ -3422,14 +3422,12 @@ paths:
post:
summary: "Update a container"
description: "Change various configuration options of a container without having to recreate it."
operationId: "PostContainerUpdate"
consumes:
- "application/json"
produces:
- "application/json"
operationId: "ContainerUpdate"
consumes: ["application/json"]
produces: ["application/json"]
responses:
200:
description: "no error"
description: "The container has been updated."
schema:
type: "object"
properties:

View File

@ -0,0 +1,17 @@
package container
// ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE
// This file was generated by `swagger generate operation`
//
// See hack/swagger-gen.sh
// ----------------------------------------------------------------------------
// ContainerUpdateOKBody container update o k body
// swagger:model ContainerUpdateOKBody
type ContainerUpdateOKBody struct {
// warnings
// Required: true
Warnings []string `json:"Warnings"`
}

View File

@ -13,13 +13,6 @@ import (
"github.com/docker/go-connections/nat"
)
// ContainerUpdateResponse contains response of Remote API:
// POST "/containers/{name:.*}/update"
type ContainerUpdateResponse struct {
// Warnings are any warnings encountered during the updating of the container.
Warnings []string `json:"Warnings"`
}
// AuthResponse contains response of Remote API:
// POST "/auth"
type AuthResponse struct {

View File

@ -3,14 +3,13 @@ package client
import (
"encoding/json"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"golang.org/x/net/context"
)
// ContainerUpdate updates resources of a container
func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) {
var response types.ContainerUpdateResponse
func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) {
var response container.ContainerUpdateOKBody
serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
if err != nil {
return response, err

View File

@ -9,7 +9,6 @@ import (
"strings"
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"golang.org/x/net/context"
)
@ -33,7 +32,7 @@ func TestContainerUpdate(t *testing.T) {
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
}
b, err := json.Marshal(types.ContainerUpdateResponse{})
b, err := json.Marshal(container.ContainerUpdateOKBody{})
if err != nil {
return nil, err
}

View File

@ -58,7 +58,7 @@ type ContainerAPIClient interface {
ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error)
ContainerUnpause(ctx context.Context, container string) error
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error)
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
ContainerWait(ctx context.Context, container string) (int, 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

View File

@ -3,24 +3,23 @@ package daemon
import (
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
)
// ContainerUpdate updates configuration of the container
func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (types.ContainerUpdateResponse, error) {
func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (container.ContainerUpdateOKBody, error) {
var warnings []string
warnings, err := daemon.verifyContainerSettings(hostConfig, nil, true, validateHostname)
if err != nil {
return types.ContainerUpdateResponse{Warnings: warnings}, err
return container.ContainerUpdateOKBody{Warnings: warnings}, err
}
if err := daemon.update(name, hostConfig); err != nil {
return types.ContainerUpdateResponse{Warnings: warnings}, err
return container.ContainerUpdateOKBody{Warnings: warnings}, err
}
return types.ContainerUpdateResponse{Warnings: warnings}, nil
return container.ContainerUpdateOKBody{Warnings: warnings}, nil
}
// ContainerUpdateCmdOnBuild updates Path and Args for the container with ID cID.

View File

@ -15,4 +15,5 @@ swagger generate operation -f api/swagger.yaml \
-T api/templates --skip-responses --skip-parameters --skip-validator \
-n VolumesList \
-n VolumesCreate \
-n ContainerCreate
-n ContainerCreate \
-n ContainerUpdate