Generate container update response from swagger spec.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
c8d5e7203e
commit
f196cf6a09
|
@ -42,7 +42,7 @@ type stateBackend interface {
|
||||||
ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool, checkpoint string, checkpointDir string) error
|
ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool, checkpoint string, checkpointDir string) error
|
||||||
ContainerStop(name string, seconds *int) error
|
ContainerStop(name string, seconds *int) error
|
||||||
ContainerUnpause(name string) 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)
|
ContainerWait(name string, timeout time.Duration) (int, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3422,14 +3422,12 @@ paths:
|
||||||
post:
|
post:
|
||||||
summary: "Update a container"
|
summary: "Update a container"
|
||||||
description: "Change various configuration options of a container without having to recreate it."
|
description: "Change various configuration options of a container without having to recreate it."
|
||||||
operationId: "PostContainerUpdate"
|
operationId: "ContainerUpdate"
|
||||||
consumes:
|
consumes: ["application/json"]
|
||||||
- "application/json"
|
produces: ["application/json"]
|
||||||
produces:
|
|
||||||
- "application/json"
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: "no error"
|
description: "The container has been updated."
|
||||||
schema:
|
schema:
|
||||||
type: "object"
|
type: "object"
|
||||||
properties:
|
properties:
|
||||||
|
|
|
@ -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"`
|
||||||
|
}
|
|
@ -13,13 +13,6 @@ import (
|
||||||
"github.com/docker/go-connections/nat"
|
"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:
|
// AuthResponse contains response of Remote API:
|
||||||
// POST "/auth"
|
// POST "/auth"
|
||||||
type AuthResponse struct {
|
type AuthResponse struct {
|
||||||
|
|
|
@ -3,14 +3,13 @@ package client
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContainerUpdate updates resources of a container
|
// ContainerUpdate updates resources of a container
|
||||||
func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) {
|
func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) {
|
||||||
var response types.ContainerUpdateResponse
|
var response container.ContainerUpdateOKBody
|
||||||
serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
|
serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return response, err
|
return response, err
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"golang.org/x/net/context"
|
"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)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ type ContainerAPIClient interface {
|
||||||
ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
|
ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
|
||||||
ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error)
|
ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error)
|
||||||
ContainerUnpause(ctx context.Context, container string) 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)
|
ContainerWait(ctx context.Context, container string) (int, error)
|
||||||
CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, 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
|
CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
|
||||||
|
|
|
@ -3,24 +3,23 @@ package daemon
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContainerUpdate updates configuration of the 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
|
var warnings []string
|
||||||
|
|
||||||
warnings, err := daemon.verifyContainerSettings(hostConfig, nil, true, validateHostname)
|
warnings, err := daemon.verifyContainerSettings(hostConfig, nil, true, validateHostname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.ContainerUpdateResponse{Warnings: warnings}, err
|
return container.ContainerUpdateOKBody{Warnings: warnings}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := daemon.update(name, hostConfig); err != nil {
|
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.
|
// ContainerUpdateCmdOnBuild updates Path and Args for the container with ID cID.
|
||||||
|
|
|
@ -15,4 +15,5 @@ swagger generate operation -f api/swagger.yaml \
|
||||||
-T api/templates --skip-responses --skip-parameters --skip-validator \
|
-T api/templates --skip-responses --skip-parameters --skip-validator \
|
||||||
-n VolumesList \
|
-n VolumesList \
|
||||||
-n VolumesCreate \
|
-n VolumesCreate \
|
||||||
-n ContainerCreate
|
-n ContainerCreate \
|
||||||
|
-n ContainerUpdate
|
||||||
|
|
Loading…
Reference in New Issue