Merge pull request #28409 from dnephin/swagger-gen-more

Generate more types from the swagger spec
This commit is contained in:
Alexander Morozov 2017-01-26 10:35:34 -08:00 коммит произвёл GitHub
Родитель 5497f4758d 17f9f5abf4
Коммит a69c4129e0
25 изменённых файлов: 265 добавлений и 139 удалений

Просмотреть файл

@ -53,7 +53,7 @@ type monitorBackend interface {
ContainerInspect(name string, size bool, version string) (interface{}, error)
ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)
ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error)
Containers(config *types.ContainerListOptions) ([]*types.Container, error)
}

Просмотреть файл

@ -6,6 +6,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/registry"
"golang.org/x/net/context"
)
@ -24,8 +25,8 @@ type containerBackend interface {
}
type imageBackend interface {
ImageDelete(imageRef string, force, prune bool) ([]types.ImageDelete, error)
ImageHistory(imageName string) ([]*types.ImageHistory, error)
ImageDelete(imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
ImageHistory(imageName string) ([]*image.HistoryResponseItem, error)
Images(imageFilters filters.Args, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error)
LookupImage(name string) (*types.ImageInspect, error)
TagImage(imageName, repository, tag string) error

Просмотреть файл

@ -829,22 +829,40 @@ definitions:
items:
$ref: "#/definitions/Port"
GraphDriver:
description: "Information about this container's graph driver."
GraphDriverData:
description: "Information about a container's graph driver."
type: "object"
required: [Name, Data]
properties:
Name:
type: "string"
x-nullable: false
Data:
type: "object"
x-nullable: false
additionalProperties:
type: "string"
Image:
type: "object"
required:
- Id
- Parent
- Comment
- Created
- Container
- DockerVersion
- Author
- Architecture
- Os
- Size
- VirtualSize
- GraphDriver
- RootFS
properties:
Id:
type: "string"
x-nullable: false
RepoTags:
type: "array"
items:
@ -855,37 +873,51 @@ definitions:
type: "string"
Parent:
type: "string"
x-nullable: false
Comment:
type: "string"
x-nullable: false
Created:
type: "string"
x-nullable: false
Container:
type: "string"
x-nullable: false
ContainerConfig:
$ref: "#/definitions/Config"
DockerVersion:
type: "string"
x-nullable: false
Author:
type: "string"
x-nullable: false
Config:
$ref: "#/definitions/Config"
Architecture:
type: "string"
x-nullable: false
Os:
type: "string"
x-nullable: false
OsVersion:
type: "string"
Size:
type: "integer"
format: "int64"
x-nullable: false
VirtualSize:
type: "integer"
format: "int64"
x-nullable: false
GraphDriver:
$ref: "#/definitions/GraphDriver"
$ref: "#/definitions/GraphDriverData"
RootFS:
type: "object"
required: [Type]
properties:
Type:
type: "string"
x-nullable: false
Layers:
type: "array"
items:
@ -2302,7 +2334,7 @@ definitions:
-
NetworkID: "4qvuz4ko70xaltuqbt8956gd1"
Addr: "10.255.0.3/16"
ImageDeleteResponse:
ImageDeleteResponseItem:
type: "object"
properties:
Untagged:
@ -2899,7 +2931,7 @@ paths:
HostConfig:
$ref: "#/definitions/HostConfig"
GraphDriver:
$ref: "#/definitions/GraphDriver"
$ref: "#/definitions/GraphDriverData"
SizeRw:
description: "The size of files that have been created or changed by this container."
type: "integer"
@ -3231,32 +3263,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"
@ -3315,12 +3349,14 @@ paths:
get:
summary: "Get container stats based on resource usage"
description: |
This endpoint returns a live stream of a containers resource usage statistics.
This endpoint returns a live stream of a containers resource usage
statistics.
The `precpu_stats` is the CPU statistic of last read, which is used for calculating the CPU usage percentage. It is not the same as the `cpu_stats` field.
The `precpu_stats` is the CPU statistic of last read, which is used
for calculating the CPU usage percentage. It is not the same as the
`cpu_stats` field.
operationId: "ContainerStats"
produces:
- "application/json"
produces: ["application/json"]
responses:
200:
description: "no error"
@ -4042,7 +4078,7 @@ paths:
head:
summary: "Get information about files in a container"
description: "A response header `X-Docker-Container-Path-Stat` is return containing a base64 - encoded JSON object with some filesystem header information about the path."
operationId: "ContainerArchiveHead"
operationId: "ContainerArchiveInfo"
responses:
200:
description: "no error"
@ -4087,9 +4123,8 @@ paths:
get:
summary: "Get an archive of a filesystem resource in a container"
description: "Get a tar archive of a resource in the filesystem of container id."
operationId: "ContainerGetArchive"
produces:
- "application/x-tar"
operationId: "ContainerArchive"
produces: ["application/x-tar"]
responses:
200:
description: "no error"
@ -4130,10 +4165,8 @@ paths:
put:
summary: "Extract an archive of files or folders to a directory in a container"
description: "Upload a tar archive to be extracted to a path in the filesystem of container id."
operationId: "ContainerPutArchive"
consumes:
- "application/x-tar"
- "application/octet-stream"
operationId: "PutContainerArchive"
consumes: ["application/x-tar", "application/octet-stream"]
responses:
200:
description: "The content was extracted successfully"
@ -4533,6 +4566,7 @@ paths:
Created: "2015-09-10T08:30:53.26995814Z"
GraphDriver:
Name: "aufs"
Data: {}
RepoDigests:
- "localhost:5000/test/busybox/example@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
RepoTags:
@ -4591,23 +4625,27 @@ paths:
summary: "Get the history of an image"
description: "Return parent layers of an image."
operationId: "ImageHistory"
produces:
- "application/json"
produces: ["application/json"]
responses:
200:
description: "No error"
description: "List of image layers"
schema:
type: "array"
items:
type: "object"
x-go-name: HistoryResponseItem
required: [Id, Created, CreatedBy, Tags, Size, Comment]
properties:
Id:
type: "string"
x-nullable: false
Created:
type: "integer"
format: "int64"
x-nullable: false
CreatedBy:
type: "string"
x-nullable: false
Tags:
type: "array"
items:
@ -4615,8 +4653,10 @@ paths:
Size:
type: "integer"
format: "int64"
x-nullable: false
Comment:
type: "string"
x-nullable: false
examples:
application/json:
- Id: "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710"
@ -4738,19 +4778,20 @@ paths:
delete:
summary: "Remove an image"
description: |
Remove an image, along with any untagged parent images that were referenced by that image.
Remove an image, along with any untagged parent images that were
referenced by that image.
Images can't be removed if they have descendant images, are being used by a running container or are being used by a build.
Images can't be removed if they have descendant images, are being
used by a running container or are being used by a build.
operationId: "ImageDelete"
produces:
- "application/json"
produces: ["application/json"]
responses:
200:
description: "No error"
description: "The image was deleted successfully"
schema:
type: "array"
items:
$ref: "#/definitions/ImageDeleteResponse"
$ref: "#/definitions/ImageDeleteResponseItem"
examples:
application/json:
- Untagged: "3e2f21a89f"
@ -4879,7 +4920,7 @@ paths:
description: "Images that were deleted"
type: "array"
items:
$ref: "#/definitions/ImageDeleteResponse"
$ref: "#/definitions/ImageDeleteResponseItem"
SpaceReclaimed:
description: "Disk space reclaimed in bytes"
type: "integer"
@ -5145,8 +5186,7 @@ paths:
summary: "Get version"
description: "Returns the version of Docker that is running and various information about the system that Docker is running on."
operationId: "SystemVersion"
produces:
- "application/json"
produces: ["application/json"]
responses:
200:
description: "no error"
@ -5195,14 +5235,20 @@ paths:
summary: "Ping"
description: "This is a dummy endpoint you can use to test if the server is accessible."
operationId: "SystemPing"
produces:
- "text/plain"
produces: ["text/plain"]
responses:
200:
description: "no error"
schema:
type: "string"
example: "OK"
headers:
API-Version:
type: "string"
description: "Max API Version the server supports"
Docker-Experimental:
type: "boolean"
description: "If the server is running with experimental mode enabled"
500:
description: "server error"
schema:
@ -7293,7 +7339,7 @@ paths:
200:
description: "no error"
schema:
$ref: "#/definitions/ImageDeleteResponse"
$ref: "#/definitions/ServiceUpdateResponse"
400:
description: "bad parameter"
schema:

Просмотреть файл

@ -0,0 +1,21 @@
package container
// ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE
// This file was generated by `swagger generate operation`
//
// See hack/generate-swagger-api.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,0 +1,21 @@
package container
// ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE
// This file was generated by `swagger generate operation`
//
// See hack/generate-swagger-api.sh
// ----------------------------------------------------------------------------
// ContainerTopOKBody container top o k body
// swagger:model ContainerTopOKBody
type ContainerTopOKBody struct {
// Each process running in the container, where each is process is an array of values corresponding to the titles
// Required: true
Processes [][]string `json:"Processes"`
// The ps column titles
// Required: true
Titles []string `json:"Titles"`
}

Просмотреть файл

@ -0,0 +1,17 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// GraphDriverData Information about a container's graph driver.
// swagger:model GraphDriverData
type GraphDriverData struct {
// data
// Required: true
Data map[string]string `json:"Data"`
// name
// Required: true
Name string `json:"Name"`
}

Просмотреть файл

@ -0,0 +1,37 @@
package image
// ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE
// This file was generated by `swagger generate operation`
//
// See hack/generate-swagger-api.sh
// ----------------------------------------------------------------------------
// HistoryResponseItem history response item
// swagger:model HistoryResponseItem
type HistoryResponseItem struct {
// comment
// Required: true
Comment string `json:"Comment"`
// created
// Required: true
Created int64 `json:"Created"`
// created by
// Required: true
CreatedBy string `json:"CreatedBy"`
// Id
// Required: true
ID string `json:"Id"`
// size
// Required: true
Size int64 `json:"Size"`
// tags
// Required: true
Tags []string `json:"Tags"`
}

Просмотреть файл

@ -0,0 +1,15 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// ImageDeleteResponseItem image delete response item
// swagger:model ImageDeleteResponseItem
type ImageDeleteResponseItem struct {
// The image ID of an image that was deleted
Deleted string `json:"Deleted,omitempty"`
// The image ID of an image that was untagged
Untagged string `json:"Untagged,omitempty"`
}

Просмотреть файл

@ -17,38 +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"
type ImageHistory struct {
ID string `json:"Id"`
Created int64
CreatedBy string
Tags []string
Size int64
Comment string
}
// ImageDelete contains response of Engine API:
// DELETE "/images/{name:.*}"
type ImageDelete struct {
Untagged string `json:",omitempty"`
Deleted string `json:",omitempty"`
}
// GraphDriverData returns Image's graph driver config info
// when calling inspect command
type GraphDriverData struct {
Name string
Data map[string]string
}
// RootFS returns Image's RootFS description including the layer IDs.
type RootFS struct {
Type string
@ -125,13 +93,6 @@ type ContainerStats struct {
OSType string `json:"ostype"`
}
// ContainerProcessList contains response of Engine API:
// GET "/containers/{name:.*}/top"
type ContainerProcessList struct {
Processes [][]string
Titles []string
}
// Ping contains response of Engine API:
// GET "/_ping"
type Ping struct {
@ -526,7 +487,7 @@ type VolumesPruneReport struct {
// ImagesPruneReport contains the response for Engine API:
// POST "/images/prune"
type ImagesPruneReport struct {
ImagesDeleted []ImageDelete
ImagesDeleted []ImageDeleteResponseItem
SpaceReclaimed uint64
}

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -5,13 +5,13 @@ import (
"net/url"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"golang.org/x/net/context"
)
// ContainerTop shows process information from within a container.
func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (types.ContainerProcessList, error) {
var response types.ContainerProcessList
func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (container.ContainerTopOKBody, error) {
var response container.ContainerTopOKBody
query := url.Values{}
if len(arguments) > 0 {
query.Set("ps_args", strings.Join(arguments, " "))

Просмотреть файл

@ -10,7 +10,7 @@ import (
"strings"
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"golang.org/x/net/context"
)
@ -43,7 +43,7 @@ func TestContainerTop(t *testing.T) {
return nil, fmt.Errorf("args not set in URL query properly. Expected 'arg1 arg2', got %v", args)
}
b, err := json.Marshal(types.ContainerProcessList{
b, err := json.Marshal(container.ContainerTopOKBody{
Processes: [][]string{
{"p1", "p2"},
{"p3"},

Просмотреть файл

@ -4,13 +4,13 @@ import (
"encoding/json"
"net/url"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/image"
"golang.org/x/net/context"
)
// ImageHistory returns the changes in an image in history format.
func (cli *Client) ImageHistory(ctx context.Context, imageID string) ([]types.ImageHistory, error) {
var history []types.ImageHistory
func (cli *Client) ImageHistory(ctx context.Context, imageID string) ([]image.HistoryResponseItem, error) {
var history []image.HistoryResponseItem
serverResp, err := cli.get(ctx, "/images/"+imageID+"/history", url.Values{}, nil)
if err != nil {
return history, err

Просмотреть файл

@ -9,7 +9,7 @@ import (
"strings"
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/image"
"golang.org/x/net/context"
)
@ -30,7 +30,7 @@ func TestImageHistory(t *testing.T) {
if !strings.HasPrefix(r.URL.Path, expectedURL) {
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, r.URL)
}
b, err := json.Marshal([]types.ImageHistory{
b, err := json.Marshal([]image.HistoryResponseItem{
{
ID: "image_id1",
Tags: []string{"tag1", "tag2"},

Просмотреть файл

@ -9,7 +9,7 @@ import (
)
// ImageRemove removes an image from the docker host.
func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDelete, error) {
func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) {
query := url.Values{}
if options.Force {
@ -24,7 +24,7 @@ func (cli *Client) ImageRemove(ctx context.Context, imageID string, options type
return nil, err
}
var dels []types.ImageDelete
var dels []types.ImageDeleteResponseItem
err = json.NewDecoder(resp.body).Decode(&dels)
ensureReaderClosed(resp)
return dels, err

Просмотреть файл

@ -63,7 +63,7 @@ func TestImageRemove(t *testing.T) {
return nil, fmt.Errorf("%s not set in URL query properly. Expected '%s', got %s", key, expected, actual)
}
}
b, err := json.Marshal([]types.ImageDelete{
b, err := json.Marshal([]types.ImageDeleteResponseItem{
{
Untagged: "image_id1",
},

Просмотреть файл

@ -8,6 +8,7 @@ import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm"
@ -37,7 +38,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)
@ -58,7 +59,7 @@ type ContainerAPIClient interface {
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) 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) (container.ContainerTopOKBody, error)
ContainerUnpause(ctx context.Context, container string) error
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
ContainerWait(ctx context.Context, container string) (int64, error)
@ -71,14 +72,14 @@ type ContainerAPIClient interface {
type ImageAPIClient interface {
ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
ImageHistory(ctx context.Context, image string) ([]types.ImageHistory, error)
ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error)
ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error)
ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDelete, error)
ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error)
ImageSave(ctx context.Context, images []string) (io.ReadCloser, error)
ImageTag(ctx context.Context, image, ref string) error

Просмотреть файл

@ -61,9 +61,9 @@ const (
// FIXME: remove ImageDelete's dependency on Daemon, then move to the graph
// package. This would require that we no longer need the daemon to determine
// whether images are being used by a stopped or running container.
func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.ImageDelete, error) {
func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) {
start := time.Now()
records := []types.ImageDelete{}
records := []types.ImageDeleteResponseItem{}
imgID, err := daemon.GetImageID(imageRef)
if err != nil {
@ -99,7 +99,7 @@ func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.I
return nil, err
}
untaggedRecord := types.ImageDelete{Untagged: parsedRef.String()}
untaggedRecord := types.ImageDeleteResponseItem{Untagged: parsedRef.String()}
daemon.LogImageEvent(imgID.String(), imgID.String(), "untag")
records = append(records, untaggedRecord)
@ -126,7 +126,7 @@ func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.I
return records, err
}
untaggedRecord := types.ImageDelete{Untagged: repoRef.String()}
untaggedRecord := types.ImageDeleteResponseItem{Untagged: repoRef.String()}
records = append(records, untaggedRecord)
} else {
remainingRefs = append(remainingRefs, repoRef)
@ -162,7 +162,7 @@ func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.I
return nil, err
}
untaggedRecord := types.ImageDelete{Untagged: parsedRef.String()}
untaggedRecord := types.ImageDeleteResponseItem{Untagged: parsedRef.String()}
daemon.LogImageEvent(imgID.String(), imgID.String(), "untag")
records = append(records, untaggedRecord)
@ -244,9 +244,9 @@ func (daemon *Daemon) removeImageRef(ref reference.Named) (reference.Named, erro
// removeAllReferencesToImageID attempts to remove every reference to the given
// imgID from this daemon's store of repository tag/digest references. Returns
// on the first encountered error. Removed references are logged to this
// daemon's event service. An "Untagged" types.ImageDelete is added to the
// daemon's event service. An "Untagged" types.ImageDeleteResponseItem is added to the
// given list of records.
func (daemon *Daemon) removeAllReferencesToImageID(imgID image.ID, records *[]types.ImageDelete) error {
func (daemon *Daemon) removeAllReferencesToImageID(imgID image.ID, records *[]types.ImageDeleteResponseItem) error {
imageRefs := daemon.referenceStore.References(imgID.Digest())
for _, imageRef := range imageRefs {
@ -255,7 +255,7 @@ func (daemon *Daemon) removeAllReferencesToImageID(imgID image.ID, records *[]ty
return err
}
untaggedRecord := types.ImageDelete{Untagged: parsedRef.String()}
untaggedRecord := types.ImageDeleteResponseItem{Untagged: parsedRef.String()}
daemon.LogImageEvent(imgID.String(), imgID.String(), "untag")
*records = append(*records, untaggedRecord)
@ -295,7 +295,7 @@ func (idc *imageDeleteConflict) Error() string {
// conflict is encountered, it will be returned immediately without deleting
// the image. If quiet is true, any encountered conflicts will be ignored and
// the function will return nil immediately without deleting the image.
func (daemon *Daemon) imageDeleteHelper(imgID image.ID, records *[]types.ImageDelete, force, prune, quiet bool) error {
func (daemon *Daemon) imageDeleteHelper(imgID image.ID, records *[]types.ImageDeleteResponseItem, force, prune, quiet bool) error {
// First, determine if this image has any conflicts. Ignore soft conflicts
// if force is true.
c := conflictHard
@ -331,9 +331,9 @@ func (daemon *Daemon) imageDeleteHelper(imgID image.ID, records *[]types.ImageDe
}
daemon.LogImageEvent(imgID.String(), imgID.String(), "delete")
*records = append(*records, types.ImageDelete{Deleted: imgID.String()})
*records = append(*records, types.ImageDeleteResponseItem{Deleted: imgID.String()})
for _, removedLayer := range removedLayers {
*records = append(*records, types.ImageDelete{Deleted: removedLayer.ChainID.String()})
*records = append(*records, types.ImageDeleteResponseItem{Deleted: removedLayer.ChainID.String()})
}
if !prune || parent == "" {

Просмотреть файл

@ -4,21 +4,21 @@ import (
"fmt"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/reference"
)
// ImageHistory returns a slice of ImageHistory structures for the specified image
// name by walking the image lineage.
func (daemon *Daemon) ImageHistory(name string) ([]*types.ImageHistory, error) {
func (daemon *Daemon) ImageHistory(name string) ([]*image.HistoryResponseItem, error) {
start := time.Now()
img, err := daemon.GetImage(name)
if err != nil {
return nil, err
}
history := []*types.ImageHistory{}
history := []*image.HistoryResponseItem{}
layerCounter := 0
rootFS := *img.RootFS
@ -46,7 +46,7 @@ func (daemon *Daemon) ImageHistory(name string) ([]*types.ImageHistory, error) {
layerCounter++
}
history = append([]*types.ImageHistory{{
history = append([]*image.HistoryResponseItem{{
ID: "<missing>",
Created: h.Created.Unix(),
CreatedBy: h.CreatedBy,

Просмотреть файл

@ -132,7 +132,7 @@ func (daemon *Daemon) ImagesPrune(pruneFilters filters.Args) (*types.ImagesPrune
continue
}
deletedImages := []types.ImageDelete{}
deletedImages := []types.ImageDeleteResponseItem{}
refs := daemon.referenceStore.References(dgst)
if len(refs) > 0 {
shouldDelete := !danglingOnly

Просмотреть файл

@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
)
func validatePSArgs(psArgs string) error {
@ -41,8 +41,8 @@ func fieldsASCII(s string) []string {
return strings.FieldsFunc(s, fn)
}
func parsePSOutput(output []byte, pids []int) (*types.ContainerProcessList, error) {
procList := &types.ContainerProcessList{}
func parsePSOutput(output []byte, pids []int) (*container.ContainerTopOKBody, error) {
procList := &container.ContainerTopOKBody{}
lines := strings.Split(string(output), "\n")
procList.Titles = fieldsASCII(lines[0])
@ -86,7 +86,7 @@ func parsePSOutput(output []byte, pids []int) (*types.ContainerProcessList, erro
// "-ef" if no args are given. An error is returned if the container
// is not found, or is not running, or if there are any problems
// running ps, or parsing the output.
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error) {
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error) {
if psArgs == "" {
psArgs = "-ef"
}

Просмотреть файл

@ -5,7 +5,7 @@ import (
"fmt"
"time"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/go-units"
)
@ -23,7 +23,7 @@ import (
// task manager does and use the private working set as the memory counter.
// We could return more info for those who really understand how memory
// management works in Windows if we introduced a "raw" stats (above).
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error) {
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*containertypes.ContainerTopOKBody, error) {
// It's not at all an equivalent to linux 'ps' on Windows
if psArgs != "" {
return nil, errors.New("Windows does not support arguments to top")
@ -38,7 +38,7 @@ func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.Container
if err != nil {
return nil, err
}
procList := &types.ContainerProcessList{}
procList := &containertypes.ContainerTopOKBody{}
procList.Titles = []string{"Name", "PID", "CPU", "Private Working Set"}
for _, j := range s {

Просмотреть файл

@ -3,20 +3,25 @@ set -eu
swagger generate model -f api/swagger.yaml \
-t api -m types --skip-validator -C api/swagger-gen.yaml \
-n Volume \
-n Port \
-n ErrorResponse \
-n GraphDriverData \
-n IdResponse \
-n ImageDeleteResponseItem \
-n ImageSummary \
-n Plugin -n PluginDevice -n PluginMount -n PluginEnv -n PluginInterfaceType \
-n ErrorResponse \
-n IdResponse \
-n ServiceUpdateResponse
-n Port \
-n ServiceUpdateResponse \
-n Volume
swagger generate operation -f api/swagger.yaml \
-t api -a types -m types -C api/swagger-gen.yaml \
-T api/templates --skip-responses --skip-parameters --skip-validator \
-n VolumesList \
-n VolumesCreate \
-n ContainerCreate \
-n ContainerUpdate \
-n Authenticate \
-n ContainerWait
-n ContainerChanges \
-n ContainerCreate \
-n ContainerTop \
-n ContainerUpdate \
-n ContainerWait \
-n ImageHistory \
-n VolumesCreate \
-n VolumesList

Просмотреть файл

@ -7,6 +7,7 @@ import (
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/request"
"github.com/go-check/check"
@ -106,7 +107,7 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK)
var historydata []types.ImageHistory
var historydata []image.HistoryResponseItem
err = json.Unmarshal(body, &historydata)
c.Assert(err, checker.IsNil, check.Commentf("Error on unmarshal"))