Browse Source

Generate ContainerChanges from swagger spec.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Daniel Nephin 8 years ago
parent
commit
b83d9bf6a9

+ 10 - 8
api/swagger.yaml

@@ -3266,32 +3266,34 @@ paths:
     get:
     get:
       summary: "Get changes on a container’s filesystem"
       summary: "Get changes on a container’s filesystem"
       description: |
       description: |
-        Returns which files in a container's filesystem have been added, deleted, or modified. The `Kind` of modification can be one of:
+        Returns which files in a container's filesystem have been added, deleted,
+        or modified. The `Kind` of modification can be one of:
 
 
         - `0`: Modified
         - `0`: Modified
         - `1`: Added
         - `1`: Added
         - `2`: Deleted
         - `2`: Deleted
       operationId: "ContainerChanges"
       operationId: "ContainerChanges"
-      produces:
-        - "application/json"
+      produces: ["application/json"]
       responses:
       responses:
         200:
         200:
-          description: "no error"
+          description: "The list of changes"
           schema:
           schema:
             type: "array"
             type: "array"
             items:
             items:
               type: "object"
               type: "object"
+              x-go-name: "ContainerChangeResponseItem"
+              required: [Path, Kind]
               properties:
               properties:
                 Path:
                 Path:
                   description: "Path to file that has changed"
                   description: "Path to file that has changed"
                   type: "string"
                   type: "string"
+                  x-nullable: false
                 Kind:
                 Kind:
                   description: "Kind of change"
                   description: "Kind of change"
                   type: "integer"
                   type: "integer"
-                  enum:
-                    - 0
-                    - 1
-                    - 2
+                  format: "uint8"
+                  enum: [0, 1, 2]
+                  x-nullable: false
           examples:
           examples:
             application/json:
             application/json:
               - Path: "/dev"
               - Path: "/dev"

+ 21 - 0
api/types/container/container_changes.go

@@ -0,0 +1,21 @@
+package container
+
+// ----------------------------------------------------------------------------
+// DO NOT EDIT THIS FILE
+// This file was generated by `swagger generate operation`
+//
+// See hack/swagger-gen.sh
+// ----------------------------------------------------------------------------
+
+// ContainerChangeResponseItem container change response item
+// swagger:model ContainerChangeResponseItem
+type ContainerChangeResponseItem struct {
+
+	// Kind of change
+	// Required: true
+	Kind uint8 `json:"Kind"`
+
+	// Path to file that has changed
+	// Required: true
+	Path string `json:"Path"`
+}

+ 0 - 6
api/types/types.go

@@ -17,12 +17,6 @@ import (
 	"github.com/docker/go-connections/nat"
 	"github.com/docker/go-connections/nat"
 )
 )
 
 
-// ContainerChange contains response of Engine API:
-// GET "/containers/{name:.*}/changes"
-type ContainerChange struct {
-	Kind int
-	Path string
-}
 
 
 // ImageHistory contains response of Engine API:
 // ImageHistory contains response of Engine API:
 // GET "/images/{name:.*}/history"
 // GET "/images/{name:.*}/history"

+ 3 - 3
client/container_diff.go

@@ -4,13 +4,13 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"net/url"
 	"net/url"
 
 
-	"github.com/docker/docker/api/types"
+	"github.com/docker/docker/api/types/container"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
 
 
 // ContainerDiff shows differences in a container filesystem since it was started.
 // ContainerDiff shows differences in a container filesystem since it was started.
-func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]types.ContainerChange, error) {
-	var changes []types.ContainerChange
+func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]container.ContainerChangeResponseItem, error) {
+	var changes []container.ContainerChangeResponseItem
 
 
 	serverResp, err := cli.get(ctx, "/containers/"+containerID+"/changes", url.Values{}, nil)
 	serverResp, err := cli.get(ctx, "/containers/"+containerID+"/changes", url.Values{}, nil)
 	if err != nil {
 	if err != nil {

+ 2 - 2
client/container_diff_test.go

@@ -9,7 +9,7 @@ import (
 	"strings"
 	"strings"
 	"testing"
 	"testing"
 
 
-	"github.com/docker/docker/api/types"
+	"github.com/docker/docker/api/types/container"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
 
 
@@ -31,7 +31,7 @@ func TestContainerDiff(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				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.ContainerChange{
+			b, err := json.Marshal([]container.ContainerChangeResponseItem{
 				{
 				{
 					Kind: 0,
 					Kind: 0,
 					Path: "/path/1",
 					Path: "/path/1",

+ 1 - 1
client/interface.go

@@ -37,7 +37,7 @@ type ContainerAPIClient interface {
 	ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
 	ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
 	ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
 	ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
 	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
 	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
-	ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error)
+	ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
 	ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)
 	ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)
 	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
 	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
 	ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
 	ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)

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

@@ -16,6 +16,7 @@ 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 ContainerChanges \
     -n ContainerCreate \
     -n ContainerCreate \
     -n ContainerUpdate \
     -n ContainerUpdate \
     -n Authenticate \
     -n Authenticate \