Prechádzať zdrojové kódy

Generate container update response from swagger spec.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Daniel Nephin 8 rokov pred
rodič
commit
f196cf6a09

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

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

+ 4 - 6
api/swagger.yaml

@@ -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"
-      consumes:
-        - "application/json"
-      produces:
-        - "application/json"
+      operationId: "ContainerUpdate"
+      consumes: ["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:

+ 17 - 0
api/types/container/container_update.go

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

+ 0 - 7
api/types/types.go

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

+ 2 - 3
client/container_update.go

@@ -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) {
-	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)
 	serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
 	if err != nil {
 	if err != nil {
 		return response, err
 		return response, err

+ 1 - 2
client/container_update_test.go

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

+ 1 - 1
client/interface.go

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

+ 4 - 5
daemon/update.go

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

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

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