Generate ContainerChanges from swagger spec.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-11-09 16:15:32 -05:00
parent 884a1c2263
commit b83d9bf6a9
7 changed files with 38 additions and 20 deletions

View file

@ -3266,32 +3266,34 @@ paths:
get:
summary: "Get changes on a containers filesystem"
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
- `1`: Added
- `2`: Deleted
operationId: "ContainerChanges"
produces:
- "application/json"
produces: ["application/json"]
responses:
200:
description: "no error"
description: "The list of changes"
schema:
type: "array"
items:
type: "object"
x-go-name: "ContainerChangeResponseItem"
required: [Path, Kind]
properties:
Path:
description: "Path to file that has changed"
type: "string"
x-nullable: false
Kind:
description: "Kind of change"
type: "integer"
enum:
- 0
- 1
- 2
format: "uint8"
enum: [0, 1, 2]
x-nullable: false
examples:
application/json:
- Path: "/dev"

View file

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

View file

@ -17,12 +17,6 @@ import (
"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:
// GET "/images/{name:.*}/history"

View file

@ -4,13 +4,13 @@ import (
"encoding/json"
"net/url"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"golang.org/x/net/context"
)
// 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)
if err != nil {

View file

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

View file

@ -37,7 +37,7 @@ type ContainerAPIClient interface {
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, 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)
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)
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)

View file

@ -16,6 +16,7 @@ swagger generate operation -f api/swagger.yaml \
-T api/templates --skip-responses --skip-parameters --skip-validator \
-n VolumesList \
-n VolumesCreate \
-n ContainerChanges \
-n ContainerCreate \
-n ContainerUpdate \
-n Authenticate \