Browse code

Generate container update response from swagger spec.

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2016/10/19 09:35:45
Showing 9 changed files
... ...
@@ -42,7 +42,7 @@ type stateBackend interface {
42 42
 	ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool, checkpoint string, checkpointDir string) error
43 43
 	ContainerStop(name string, seconds *int) error
44 44
 	ContainerUnpause(name string) error
45
-	ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (types.ContainerUpdateResponse, error)
45
+	ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (container.ContainerUpdateOKBody, error)
46 46
 	ContainerWait(name string, timeout time.Duration) (int, error)
47 47
 }
48 48
 
... ...
@@ -3422,14 +3422,12 @@ paths:
3422 3422
     post:
3423 3423
       summary: "Update a container"
3424 3424
       description: "Change various configuration options of a container without having to recreate it."
3425
-      operationId: "PostContainerUpdate"
3426
-      consumes:
3427
-        - "application/json"
3428
-      produces:
3429
-        - "application/json"
3425
+      operationId: "ContainerUpdate"
3426
+      consumes: ["application/json"]
3427
+      produces: ["application/json"]
3430 3428
       responses:
3431 3429
         200:
3432
-          description: "no error"
3430
+          description: "The container has been updated."
3433 3431
           schema:
3434 3432
             type: "object"
3435 3433
             properties:
3436 3434
new file mode 100644
... ...
@@ -0,0 +1,17 @@
0
+package container
1
+
2
+// ----------------------------------------------------------------------------
3
+// DO NOT EDIT THIS FILE
4
+// This file was generated by `swagger generate operation`
5
+//
6
+// See hack/swagger-gen.sh
7
+// ----------------------------------------------------------------------------
8
+
9
+// ContainerUpdateOKBody container update o k body
10
+// swagger:model ContainerUpdateOKBody
11
+type ContainerUpdateOKBody struct {
12
+
13
+	// warnings
14
+	// Required: true
15
+	Warnings []string `json:"Warnings"`
16
+}
... ...
@@ -13,13 +13,6 @@ import (
13 13
 	"github.com/docker/go-connections/nat"
14 14
 )
15 15
 
16
-// ContainerUpdateResponse contains response of Remote API:
17
-// POST "/containers/{name:.*}/update"
18
-type ContainerUpdateResponse struct {
19
-	// Warnings are any warnings encountered during the updating of the container.
20
-	Warnings []string `json:"Warnings"`
21
-}
22
-
23 16
 // AuthResponse contains response of Remote API:
24 17
 // POST "/auth"
25 18
 type AuthResponse struct {
... ...
@@ -3,14 +3,13 @@ package client
3 3
 import (
4 4
 	"encoding/json"
5 5
 
6
-	"github.com/docker/docker/api/types"
7 6
 	"github.com/docker/docker/api/types/container"
8 7
 	"golang.org/x/net/context"
9 8
 )
10 9
 
11 10
 // ContainerUpdate updates resources of a container
12
-func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) {
13
-	var response types.ContainerUpdateResponse
11
+func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) {
12
+	var response container.ContainerUpdateOKBody
14 13
 	serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
15 14
 	if err != nil {
16 15
 		return response, err
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	"strings"
10 10
 	"testing"
11 11
 
12
-	"github.com/docker/docker/api/types"
13 12
 	"github.com/docker/docker/api/types/container"
14 13
 	"golang.org/x/net/context"
15 14
 )
... ...
@@ -33,7 +32,7 @@ func TestContainerUpdate(t *testing.T) {
33 33
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
34 34
 			}
35 35
 
36
-			b, err := json.Marshal(types.ContainerUpdateResponse{})
36
+			b, err := json.Marshal(container.ContainerUpdateOKBody{})
37 37
 			if err != nil {
38 38
 				return nil, err
39 39
 			}
... ...
@@ -58,7 +58,7 @@ type ContainerAPIClient interface {
58 58
 	ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
59 59
 	ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error)
60 60
 	ContainerUnpause(ctx context.Context, container string) error
61
-	ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error)
61
+	ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
62 62
 	ContainerWait(ctx context.Context, container string) (int, error)
63 63
 	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
64 64
 	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
... ...
@@ -3,24 +3,23 @@ package daemon
3 3
 import (
4 4
 	"fmt"
5 5
 
6
-	"github.com/docker/docker/api/types"
7 6
 	"github.com/docker/docker/api/types/container"
8 7
 )
9 8
 
10 9
 // ContainerUpdate updates configuration of the container
11
-func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (types.ContainerUpdateResponse, error) {
10
+func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (container.ContainerUpdateOKBody, error) {
12 11
 	var warnings []string
13 12
 
14 13
 	warnings, err := daemon.verifyContainerSettings(hostConfig, nil, true, validateHostname)
15 14
 	if err != nil {
16
-		return types.ContainerUpdateResponse{Warnings: warnings}, err
15
+		return container.ContainerUpdateOKBody{Warnings: warnings}, err
17 16
 	}
18 17
 
19 18
 	if err := daemon.update(name, hostConfig); err != nil {
20
-		return types.ContainerUpdateResponse{Warnings: warnings}, err
19
+		return container.ContainerUpdateOKBody{Warnings: warnings}, err
21 20
 	}
22 21
 
23
-	return types.ContainerUpdateResponse{Warnings: warnings}, nil
22
+	return container.ContainerUpdateOKBody{Warnings: warnings}, nil
24 23
 }
25 24
 
26 25
 // ContainerUpdateCmdOnBuild updates Path and Args for the container with ID cID.
... ...
@@ -15,4 +15,5 @@ swagger generate operation -f api/swagger.yaml \
15 15
     -T api/templates --skip-responses --skip-parameters --skip-validator \
16 16
     -n VolumesList \
17 17
     -n VolumesCreate \
18
-    -n ContainerCreate
18
+    -n ContainerCreate \
19
+    -n ContainerUpdate