Browse code

Generate ContainerChanges from swagger spec.

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

Daniel Nephin authored on 2016/11/10 06:15:32
Showing 7 changed files
... ...
@@ -3266,32 +3266,34 @@ paths:
3266 3266
     get:
3267 3267
       summary: "Get changes on a container’s filesystem"
3268 3268
       description: |
3269
-        Returns which files in a container's filesystem have been added, deleted, or modified. The `Kind` of modification can be one of:
3269
+        Returns which files in a container's filesystem have been added, deleted,
3270
+        or modified. The `Kind` of modification can be one of:
3270 3271
 
3271 3272
         - `0`: Modified
3272 3273
         - `1`: Added
3273 3274
         - `2`: Deleted
3274 3275
       operationId: "ContainerChanges"
3275
-      produces:
3276
-        - "application/json"
3276
+      produces: ["application/json"]
3277 3277
       responses:
3278 3278
         200:
3279
-          description: "no error"
3279
+          description: "The list of changes"
3280 3280
           schema:
3281 3281
             type: "array"
3282 3282
             items:
3283 3283
               type: "object"
3284
+              x-go-name: "ContainerChangeResponseItem"
3285
+              required: [Path, Kind]
3284 3286
               properties:
3285 3287
                 Path:
3286 3288
                   description: "Path to file that has changed"
3287 3289
                   type: "string"
3290
+                  x-nullable: false
3288 3291
                 Kind:
3289 3292
                   description: "Kind of change"
3290 3293
                   type: "integer"
3291
-                  enum:
3292
-                    - 0
3293
-                    - 1
3294
-                    - 2
3294
+                  format: "uint8"
3295
+                  enum: [0, 1, 2]
3296
+                  x-nullable: false
3295 3297
           examples:
3296 3298
             application/json:
3297 3299
               - Path: "/dev"
3298 3300
new file mode 100644
... ...
@@ -0,0 +1,21 @@
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
+// ContainerChangeResponseItem container change response item
10
+// swagger:model ContainerChangeResponseItem
11
+type ContainerChangeResponseItem struct {
12
+
13
+	// Kind of change
14
+	// Required: true
15
+	Kind uint8 `json:"Kind"`
16
+
17
+	// Path to file that has changed
18
+	// Required: true
19
+	Path string `json:"Path"`
20
+}
... ...
@@ -17,12 +17,6 @@ import (
17 17
 	"github.com/docker/go-connections/nat"
18 18
 )
19 19
 
20
-// ContainerChange contains response of Engine API:
21
-// GET "/containers/{name:.*}/changes"
22
-type ContainerChange struct {
23
-	Kind int
24
-	Path string
25
-}
26 20
 
27 21
 // ImageHistory contains response of Engine API:
28 22
 // GET "/images/{name:.*}/history"
... ...
@@ -4,13 +4,13 @@ import (
4 4
 	"encoding/json"
5 5
 	"net/url"
6 6
 
7
-	"github.com/docker/docker/api/types"
7
+	"github.com/docker/docker/api/types/container"
8 8
 	"golang.org/x/net/context"
9 9
 )
10 10
 
11 11
 // ContainerDiff shows differences in a container filesystem since it was started.
12
-func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]types.ContainerChange, error) {
13
-	var changes []types.ContainerChange
12
+func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]container.ContainerChangeResponseItem, error) {
13
+	var changes []container.ContainerChangeResponseItem
14 14
 
15 15
 	serverResp, err := cli.get(ctx, "/containers/"+containerID+"/changes", url.Values{}, nil)
16 16
 	if err != nil {
... ...
@@ -9,7 +9,7 @@ import (
9 9
 	"strings"
10 10
 	"testing"
11 11
 
12
-	"github.com/docker/docker/api/types"
12
+	"github.com/docker/docker/api/types/container"
13 13
 	"golang.org/x/net/context"
14 14
 )
15 15
 
... ...
@@ -31,7 +31,7 @@ func TestContainerDiff(t *testing.T) {
31 31
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
32 32
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
33 33
 			}
34
-			b, err := json.Marshal([]types.ContainerChange{
34
+			b, err := json.Marshal([]container.ContainerChangeResponseItem{
35 35
 				{
36 36
 					Kind: 0,
37 37
 					Path: "/path/1",
... ...
@@ -37,7 +37,7 @@ type ContainerAPIClient interface {
37 37
 	ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
38 38
 	ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
39 39
 	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
40
-	ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error)
40
+	ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
41 41
 	ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)
42 42
 	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
43 43
 	ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
... ...
@@ -16,6 +16,7 @@ swagger generate operation -f api/swagger.yaml \
16 16
     -T api/templates --skip-responses --skip-parameters --skip-validator \
17 17
     -n VolumesList \
18 18
     -n VolumesCreate \
19
+    -n ContainerChanges \
19 20
     -n ContainerCreate \
20 21
     -n ContainerUpdate \
21 22
     -n Authenticate \