Merge pull request #27117 from dnephin/swagger-gen

Add swagger.yaml and generate a few types from the spec
This commit is contained in:
Sebastiaan van Stijn 2016-10-21 18:15:28 -07:00 committed by GitHub
commit 3c385b9f6b
27 changed files with 7350 additions and 235 deletions

View File

@ -137,3 +137,9 @@ validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isol
win: build ## cross build the binary for windows
$(DOCKER_RUN_DOCKER) hack/make.sh win
.PHONY: swagger-gen
swagger-gen:
docker run --rm -v $(PWD):/work -w /work \
--entrypoint hack/generate-swagger-api.sh \
quay.io/goswagger/swagger

View File

@ -20,7 +20,7 @@ import (
// Common constants for daemon and client.
const (
// Version of Current REST API
// DefaultVersion of Current REST API
DefaultVersion string = "1.25"
// MinVersion represents Minimum REST API version supported
@ -57,8 +57,8 @@ func (r byPortInfo) Less(i, j int) bool {
// it's used by command 'docker ps'
func DisplayablePorts(ports []types.Port) string {
type portGroup struct {
first int
last int
first uint16
last uint16
}
groupMap := make(map[string]*portGroup)
var result []string
@ -99,7 +99,7 @@ func DisplayablePorts(ports []types.Port) string {
return strings.Join(result, ", ")
}
func formGroup(key string, start, last int) string {
func formGroup(key string, start, last uint16) string {
parts := strings.Split(key, "/")
groupType := parts[0]
var ip string
@ -107,7 +107,7 @@ func formGroup(key string, start, last int) string {
ip = parts[0]
groupType = parts[1]
}
group := strconv.Itoa(start)
group := strconv.Itoa(int(start))
if start != last {
group = fmt.Sprintf("%s-%d", group, last)
}

View File

@ -25,7 +25,7 @@ type containerBackend interface {
type imageBackend interface {
ImageDelete(imageRef string, force, prune bool) ([]types.ImageDelete, error)
ImageHistory(imageName string) ([]*types.ImageHistory, error)
Images(filterArgs string, filter string, all bool, withExtraAttrs bool) ([]*types.Image, error)
Images(filterArgs string, filter string, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error)
LookupImage(name string) (*types.ImageInspect, error)
TagImage(imageName, repository, tag string) error
ImagesPrune(config *types.ImagesPruneConfig) (*types.ImagesPruneReport, error)

6836
api/swagger.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -314,3 +314,12 @@ type TaskListOptions struct {
type PluginRemoveOptions struct {
Force bool
}
// PluginInstallOptions holds parameters to install a plugin.
type PluginInstallOptions struct {
Disabled bool
AcceptAllPermissions bool
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
PrivilegeFunc RequestPrivilegeFunc
AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
}

View File

@ -0,0 +1,49 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// ImageSummary image summary
// swagger:model ImageSummary
type ImageSummary struct {
// containers
// Required: true
Containers int64 `json:"Containers"`
// created
// Required: true
Created int64 `json:"Created"`
// Id
// Required: true
ID string `json:"Id"`
// labels
// Required: true
Labels map[string]string `json:"Labels"`
// parent Id
// Required: true
ParentID string `json:"ParentId"`
// repo digests
// Required: true
RepoDigests []string `json:"RepoDigests"`
// repo tags
// Required: true
RepoTags []string `json:"RepoTags"`
// shared size
// Required: true
SharedSize int64 `json:"SharedSize"`
// size
// Required: true
Size int64 `json:"Size"`
// virtual size
// Required: true
VirtualSize int64 `json:"VirtualSize"`
}

View File

@ -1,168 +1,163 @@
package types
import (
"encoding/json"
"fmt"
)
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// PluginInstallOptions holds parameters to install a plugin.
type PluginInstallOptions struct {
Disabled bool
AcceptAllPermissions bool
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
PrivilegeFunc RequestPrivilegeFunc
AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
}
// PluginConfig represents the values of settings potentially modifiable by a user
type PluginConfig struct {
Mounts []PluginMount
Env []string
Args []string
Devices []PluginDevice
}
// Plugin represents a Docker plugin for the remote API
// Plugin A plugin for the Remote API
// swagger:model Plugin
type Plugin struct {
ID string `json:"Id,omitempty"`
Name string
Tag string
// Enabled is true when the plugin is running, is false when the plugin is not running, only installed.
Enabled bool
Config PluginConfig
Manifest PluginManifest
// config
// Required: true
Config PluginConfig `json:"Config"`
// True when the plugin is running. False when the plugin is not running, only installed.
// Required: true
Enabled bool `json:"Enabled"`
// Id
ID string `json:"Id,omitempty"`
// manifest
// Required: true
Manifest PluginManifest `json:"Manifest"`
// name
// Required: true
Name string `json:"Name"`
// tag
// Required: true
Tag string `json:"Tag"`
}
// PluginsListResponse contains the response for the remote API
type PluginsListResponse []*Plugin
// PluginConfig Settings that can be modified by users.
// swagger:model PluginConfig
type PluginConfig struct {
const (
authzDriver = "AuthzDriver"
graphDriver = "GraphDriver"
ipamDriver = "IpamDriver"
networkDriver = "NetworkDriver"
volumeDriver = "VolumeDriver"
)
// args
// Required: true
Args []string `json:"Args"`
// PluginInterfaceType represents a type that a plugin implements.
type PluginInterfaceType struct {
Prefix string // This is always "docker"
Capability string // Capability should be validated against the above list.
Version string // Plugin API version. Depends on the capability
// devices
// Required: true
Devices []PluginDevice `json:"Devices"`
// env
// Required: true
Env []string `json:"Env"`
// mounts
// Required: true
Mounts []PluginMount `json:"Mounts"`
}
// UnmarshalJSON implements json.Unmarshaler for PluginInterfaceType
func (t *PluginInterfaceType) UnmarshalJSON(p []byte) error {
versionIndex := len(p)
prefixIndex := 0
if len(p) < 2 || p[0] != '"' || p[len(p)-1] != '"' {
return fmt.Errorf("%q is not a plugin interface type", p)
}
p = p[1 : len(p)-1]
loop:
for i, b := range p {
switch b {
case '.':
prefixIndex = i
case '/':
versionIndex = i
break loop
}
}
t.Prefix = string(p[:prefixIndex])
t.Capability = string(p[prefixIndex+1 : versionIndex])
if versionIndex < len(p) {
t.Version = string(p[versionIndex+1:])
}
return nil
}
// MarshalJSON implements json.Marshaler for PluginInterfaceType
func (t *PluginInterfaceType) MarshalJSON() ([]byte, error) {
return json.Marshal(t.String())
}
// String implements fmt.Stringer for PluginInterfaceType
func (t PluginInterfaceType) String() string {
return fmt.Sprintf("%s.%s/%s", t.Prefix, t.Capability, t.Version)
}
// PluginInterface describes the interface between Docker and plugin
type PluginInterface struct {
Types []PluginInterfaceType
Socket string
}
// PluginSetting is to be embedded in other structs, if they are supposed to be
// modifiable by the user.
type PluginSetting struct {
Name string
Description string
Settable []string
}
// PluginNetwork represents the network configuration for a plugin
type PluginNetwork struct {
Type string
}
// PluginMount represents the mount configuration for a plugin
type PluginMount struct {
PluginSetting
Source *string
Destination string
Type string
Options []string
}
// PluginEnv represents an environment variable for a plugin
type PluginEnv struct {
PluginSetting
Value *string
}
// PluginArgs represents the command line arguments for a plugin
type PluginArgs struct {
PluginSetting
Value []string
}
// PluginDevice represents a device for a plugin
type PluginDevice struct {
PluginSetting
Path *string
}
// PluginUser represents the user for the plugin's process
type PluginUser struct {
UID uint32 `json:"Uid,omitempty"`
GID uint32 `json:"Gid,omitempty"`
}
// PluginManifest represents the manifest of a plugin
// PluginManifest The manifest of a plugin.
// swagger:model PluginManifest
type PluginManifest struct {
ManifestVersion string
Description string
Documentation string
Interface PluginInterface
Entrypoint []string
Workdir string
User PluginUser `json:",omitempty"`
Network PluginNetwork
Capabilities []string
Mounts []PluginMount
Devices []PluginDevice
Env []PluginEnv
Args PluginArgs
// args
// Required: true
Args PluginManifestArgs `json:"Args"`
// capabilities
// Required: true
Capabilities []string `json:"Capabilities"`
// description
// Required: true
Description string `json:"Description"`
// devices
// Required: true
Devices []PluginDevice `json:"Devices"`
// documentation
// Required: true
Documentation string `json:"Documentation"`
// entrypoint
// Required: true
Entrypoint []string `json:"Entrypoint"`
// env
// Required: true
Env []PluginEnv `json:"Env"`
// interface
// Required: true
Interface PluginManifestInterface `json:"Interface"`
// manifest version
// Required: true
ManifestVersion string `json:"ManifestVersion"`
// mounts
// Required: true
Mounts []PluginMount `json:"Mounts"`
// network
// Required: true
Network PluginManifestNetwork `json:"Network"`
// user
User PluginManifestUser `json:"User,omitempty"`
// workdir
// Required: true
Workdir string `json:"Workdir"`
}
// PluginPrivilege describes a permission the user has to accept
// upon installing a plugin.
type PluginPrivilege struct {
Name string
Description string
Value []string
// PluginManifestArgs plugin manifest args
// swagger:model PluginManifestArgs
type PluginManifestArgs struct {
// description
// Required: true
Description string `json:"Description"`
// name
// Required: true
Name string `json:"Name"`
// settable
// Required: true
Settable []string `json:"Settable"`
// value
// Required: true
Value []string `json:"Value"`
}
// PluginPrivileges is a list of PluginPrivilege
type PluginPrivileges []PluginPrivilege
// PluginManifestInterface The interface between Docker and the plugin
// swagger:model PluginManifestInterface
type PluginManifestInterface struct {
// socket
// Required: true
Socket string `json:"Socket"`
// types
// Required: true
Types []PluginInterfaceType `json:"Types"`
}
// PluginManifestNetwork plugin manifest network
// swagger:model PluginManifestNetwork
type PluginManifestNetwork struct {
// type
// Required: true
Type string `json:"Type"`
}
// PluginManifestUser plugin manifest user
// swagger:model PluginManifestUser
type PluginManifestUser struct {
// g ID
GID uint32 `json:"GID,omitempty"`
// UID
UID uint32 `json:"UID,omitempty"`
}

View File

@ -0,0 +1,25 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// PluginDevice plugin device
// swagger:model PluginDevice
type PluginDevice struct {
// description
// Required: true
Description string `json:"Description"`
// name
// Required: true
Name string `json:"Name"`
// path
// Required: true
Path *string `json:"Path"`
// settable
// Required: true
Settable []string `json:"Settable"`
}

25
api/types/plugin_env.go Normal file
View File

@ -0,0 +1,25 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// PluginEnv plugin env
// swagger:model PluginEnv
type PluginEnv struct {
// description
// Required: true
Description string `json:"Description"`
// name
// Required: true
Name string `json:"Name"`
// settable
// Required: true
Settable []string `json:"Settable"`
// value
// Required: true
Value *string `json:"Value"`
}

View File

@ -0,0 +1,21 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// PluginInterfaceType plugin interface type
// swagger:model PluginInterfaceType
type PluginInterfaceType struct {
// capability
// Required: true
Capability string `json:"Capability"`
// prefix
// Required: true
Prefix string `json:"Prefix"`
// version
// Required: true
Version string `json:"Version"`
}

37
api/types/plugin_mount.go Normal file
View File

@ -0,0 +1,37 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// PluginMount plugin mount
// swagger:model PluginMount
type PluginMount struct {
// description
// Required: true
Description string `json:"Description"`
// destination
// Required: true
Destination string `json:"Destination"`
// name
// Required: true
Name string `json:"Name"`
// options
// Required: true
Options []string `json:"Options"`
// settable
// Required: true
Settable []string `json:"Settable"`
// source
// Required: true
Source *string `json:"Source"`
// type
// Required: true
Type string `json:"Type"`
}

View File

@ -0,0 +1,64 @@
package types
import (
"encoding/json"
"fmt"
)
// PluginsListResponse contains the response for the remote API
type PluginsListResponse []*Plugin
const (
authzDriver = "AuthzDriver"
graphDriver = "GraphDriver"
ipamDriver = "IpamDriver"
networkDriver = "NetworkDriver"
volumeDriver = "VolumeDriver"
)
// UnmarshalJSON implements json.Unmarshaler for PluginInterfaceType
func (t *PluginInterfaceType) UnmarshalJSON(p []byte) error {
versionIndex := len(p)
prefixIndex := 0
if len(p) < 2 || p[0] != '"' || p[len(p)-1] != '"' {
return fmt.Errorf("%q is not a plugin interface type", p)
}
p = p[1 : len(p)-1]
loop:
for i, b := range p {
switch b {
case '.':
prefixIndex = i
case '/':
versionIndex = i
break loop
}
}
t.Prefix = string(p[:prefixIndex])
t.Capability = string(p[prefixIndex+1 : versionIndex])
if versionIndex < len(p) {
t.Version = string(p[versionIndex+1:])
}
return nil
}
// MarshalJSON implements json.Marshaler for PluginInterfaceType
func (t *PluginInterfaceType) MarshalJSON() ([]byte, error) {
return json.Marshal(t.String())
}
// String implements fmt.Stringer for PluginInterfaceType
func (t PluginInterfaceType) String() string {
return fmt.Sprintf("%s.%s/%s", t.Prefix, t.Capability, t.Version)
}
// PluginPrivilege describes a permission the user has to accept
// upon installing a plugin.
type PluginPrivilege struct {
Name string
Description string
Value []string
}
// PluginPrivileges is a list of PluginPrivilege
type PluginPrivileges []PluginPrivilege

23
api/types/port.go Normal file
View File

@ -0,0 +1,23 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// Port An open port on a container
// swagger:model Port
type Port struct {
// IP
IP string `json:"IP,omitempty"`
// Port on the container
// Required: true
PrivatePort uint16 `json:"PrivatePort"`
// Port exposed on the host
PublicPort uint16 `json:"PublicPort,omitempty"`
// type
// Required: true
Type string `json:"Type"`
}

View File

@ -86,21 +86,6 @@ type ImageDelete struct {
Deleted string `json:",omitempty"`
}
// Image contains response of Remote API:
// GET "/images/json"
type Image struct {
ID string `json:"Id"`
ParentID string `json:"ParentId"`
RepoTags []string
RepoDigests []string
Created int64
Size int64
SharedSize int64
VirtualSize int64
Labels map[string]string
Containers int64
}
// GraphDriverData returns Image's graph driver config info
// when calling inspect command
type GraphDriverData struct {
@ -138,15 +123,6 @@ type ImageInspect struct {
RootFS RootFS
}
// Port stores open ports info of container
// e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"}
type Port struct {
IP string `json:",omitempty"`
PrivatePort int
PublicPort int `json:",omitempty"`
Type string
}
// Container contains response of Remote API:
// GET "/containers/json"
type Container struct {
@ -433,24 +409,6 @@ type MountPoint struct {
Propagation mount.Propagation
}
// VolumeUsageData holds information regarding the volume usage
type VolumeUsageData struct {
Size int64 // Size holds how much disk space is used by the (local driver only). Sets to -1 if not provided.
RefCount int // RefCount holds the number of containers having this volume attached to them. Sets to -1 if not provided.
}
// Volume represents the configuration of a volume for the remote API
type Volume struct {
Name string // Name is the name of the volume
Driver string // Driver is the Driver name used to create the volume
Mountpoint string // Mountpoint is the location on disk of the volume
Status map[string]interface{} `json:",omitempty"` // Status provides low-level status information about the volume
Labels map[string]string // Labels is metadata specific to the volume
Scope string // Scope describes the level at which the volume exists (e.g. `global` for cluster-wide or `local` for machine level)
Options map[string]string // Options holds the driver specific options to use for when creating the volume.
UsageData *VolumeUsageData `json:",omitempty"`
}
// VolumesListResponse contains the response for the remote API:
// GET "/volumes"
type VolumesListResponse struct {
@ -543,7 +501,7 @@ type Runtime struct {
// GET "/system/df"
type DiskUsage struct {
LayersSize int64
Images []*Image
Images []*ImageSummary
Containers []*Container
Volumes []*Volume
}

58
api/types/volume.go Normal file
View File

@ -0,0 +1,58 @@
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// Volume volume
// swagger:model Volume
type Volume struct {
// Name of the volume driver used by the volume.
// Required: true
Driver string `json:"Driver"`
// A mapping of abitrary key/value data set on this volume.
// Required: true
Labels map[string]string `json:"Labels"`
// Mount path of the volume on the host.
// Required: true
Mountpoint string `json:"Mountpoint"`
// Name of the volume.
// Required: true
Name string `json:"Name"`
// The driver specific options used when creating the volume.
// Required: true
Options map[string]string `json:"Options"`
// The level at which the volume exists. Either `global` for cluster-wide, or `local` for machine level.
// Required: true
Scope string `json:"Scope"`
// Low-level details about the volume, provided by the volume driver.
// Details are returned as a map with key/value pairs:
// `{"key":"value","key2":"value2"}`.
//
// The `Status` field is optional, and is omitted if the volume driver
// does not support this feature.
//
Status map[string]interface{} `json:"Status,omitempty"`
// usage data
UsageData *VolumeUsageData `json:"UsageData,omitempty"`
}
// VolumeUsageData volume usage data
// swagger:model VolumeUsageData
type VolumeUsageData struct {
// The number of containers referencing this volume.
// Required: true
RefCount int64 `json:"RefCount"`
// The disk space used by the volume (local driver only)
// Required: true
Size int64 `json:"Size"`
}

View File

@ -31,7 +31,7 @@ type DiskUsageContext struct {
Context
Verbose bool
LayersSize int64
Images []*types.Image
Images []*types.ImageSummary
Containers []*types.Container
Volumes []*types.Volume
}
@ -155,7 +155,7 @@ func (ctx *DiskUsageContext) Write() {
type diskUsageImagesContext struct {
HeaderContext
totalSize int64
images []*types.Image
images []*types.ImageSummary
}
func (c *diskUsageImagesContext) Type() string {

View File

@ -26,7 +26,7 @@ type ImageContext struct {
Digest bool
}
func isDangling(image types.Image) bool {
func isDangling(image types.ImageSummary) bool {
return len(image.RepoTags) == 1 && image.RepoTags[0] == "<none>:<none>" && len(image.RepoDigests) == 1 && image.RepoDigests[0] == "<none>@<none>"
}
@ -72,14 +72,14 @@ virtual_size: {{.Size}}
}
// ImageWrite writes the formatter images using the ImageContext
func ImageWrite(ctx ImageContext, images []types.Image) error {
func ImageWrite(ctx ImageContext, images []types.ImageSummary) error {
render := func(format func(subContext subContext) error) error {
return imageFormat(ctx, images, format)
}
return ctx.Write(&imageContext{}, render)
}
func imageFormat(ctx ImageContext, images []types.Image, format func(subContext subContext) error) error {
func imageFormat(ctx ImageContext, images []types.ImageSummary, format func(subContext subContext) error) error {
for _, image := range images {
images := []*imageContext{}
if isDangling(image) {
@ -184,7 +184,7 @@ func imageFormat(ctx ImageContext, images []types.Image, format func(subContext
type imageContext struct {
HeaderContext
trunc bool
i types.Image
i types.ImageSummary
repo string
tag string
digest string

View File

@ -24,36 +24,36 @@ func TestImageContext(t *testing.T) {
call func() string
}{
{imageContext{
i: types.Image{ID: imageID},
i: types.ImageSummary{ID: imageID},
trunc: true,
}, stringid.TruncateID(imageID), imageIDHeader, ctx.ID},
{imageContext{
i: types.Image{ID: imageID},
i: types.ImageSummary{ID: imageID},
trunc: false,
}, imageID, imageIDHeader, ctx.ID},
{imageContext{
i: types.Image{Size: 10, VirtualSize: 10},
i: types.ImageSummary{Size: 10, VirtualSize: 10},
trunc: true,
}, "10 B", sizeHeader, ctx.Size},
{imageContext{
i: types.Image{Created: unix},
i: types.ImageSummary{Created: unix},
trunc: true,
}, time.Unix(unix, 0).String(), createdAtHeader, ctx.CreatedAt},
// FIXME
// {imageContext{
// i: types.Image{Created: unix},
// i: types.ImageSummary{Created: unix},
// trunc: true,
// }, units.HumanDuration(time.Unix(unix, 0)), createdSinceHeader, ctx.CreatedSince},
{imageContext{
i: types.Image{},
i: types.ImageSummary{},
repo: "busybox",
}, "busybox", repositoryHeader, ctx.Repository},
{imageContext{
i: types.Image{},
i: types.ImageSummary{},
tag: "latest",
}, "latest", tagHeader, ctx.Tag},
{imageContext{
i: types.Image{},
i: types.ImageSummary{},
digest: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a",
}, "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a", digestHeader, ctx.Digest},
}
@ -262,7 +262,7 @@ image_id: imageID3
}
for _, testcase := range cases {
images := []types.Image{
images := []types.ImageSummary{
{ID: "imageID1", RepoTags: []string{"image:tag1"}, RepoDigests: []string{"image@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"}, Created: unixTime},
{ID: "imageID2", RepoTags: []string{"image:tag2"}, Created: unixTime},
{ID: "imageID3", RepoTags: []string{"<none>:<none>"}, RepoDigests: []string{"<none>@<none>"}, Created: unixTime},
@ -280,7 +280,7 @@ image_id: imageID3
func TestImageContextWriteWithNoImage(t *testing.T) {
out := bytes.NewBufferString("")
images := []types.Image{}
images := []types.ImageSummary{}
contexts := []struct {
context ImageContext

View File

@ -10,8 +10,8 @@ import (
)
// ImageList returns a list of images in the docker host.
func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) {
var images []types.Image
func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) {
var images []types.ImageSummary
query := url.Values{}
if options.Filters.Len() > 0 {

View File

@ -93,7 +93,7 @@ func TestImageList(t *testing.T) {
return nil, fmt.Errorf("%s not set in URL query properly. Expected '%s', got %s", key, expected, actual)
}
}
content, err := json.Marshal([]types.Image{
content, err := json.Marshal([]types.ImageSummary{
{
ID: "image_id2",
},

View File

@ -71,7 +71,7 @@ type ImageAPIClient interface {
ImageHistory(ctx context.Context, image string) ([]types.ImageHistory, 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.Image, 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)

View File

@ -61,7 +61,7 @@ func (daemon *Daemon) SystemDiskUsage() (*types.DiskUsage, error) {
logrus.Warnf("failed to determine size of volume %v", name)
sz = -1
}
tv.UsageData = &types.VolumeUsageData{Size: sz, RefCount: len(refs)}
tv.UsageData = &types.VolumeUsageData{Size: sz, RefCount: int64(len(refs))}
allVolumes = append(allVolumes, tv)
return nil

View File

@ -22,7 +22,7 @@ var acceptedImageFilterTags = map[string]bool{
// byCreated is a temporary type used to sort a list of images by creation
// time.
type byCreated []*types.Image
type byCreated []*types.ImageSummary
func (r byCreated) Len() int { return len(r) }
func (r byCreated) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
@ -38,7 +38,7 @@ func (daemon *Daemon) Map() map[image.ID]*image.Image {
// filter is a shell glob string applied to repository names. The argument
// named all controls whether all images in the graph are filtered, or just
// the heads.
func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs bool) ([]*types.Image, error) {
func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error) {
var (
allImages map[image.ID]*image.Image
err error
@ -83,8 +83,8 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs
return nil, err
}
images := []*types.Image{}
var imagesMap map[*image.Image]*types.Image
images := []*types.ImageSummary{}
var imagesMap map[*image.Image]*types.ImageSummary
var layerRefs map[layer.ChainID]int
var allLayers map[layer.ChainID]layer.Layer
var allContainers []*container.Container
@ -181,7 +181,7 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs
if imagesMap == nil {
allContainers = daemon.List()
allLayers = daemon.layerStore.Map()
imagesMap = make(map[*image.Image]*types.Image)
imagesMap = make(map[*image.Image]*types.ImageSummary)
layerRefs = make(map[layer.ChainID]int)
}
@ -241,8 +241,8 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs
return images, nil
}
func newImage(image *image.Image, virtualSize int64) *types.Image {
newImage := new(types.Image)
func newImage(image *image.Image, virtualSize int64) *types.ImageSummary {
newImage := new(types.ImageSummary)
newImage.ParentID = image.Parent.String()
newImage.ID = image.ID().String()
newImage.Created = image.Created.Unix()

View File

@ -519,7 +519,7 @@ func (daemon *Daemon) transformContainer(container *container.Container, ctx *li
}
if len(bindings) == 0 {
newC.Ports = append(newC.Ports, types.Port{
PrivatePort: p,
PrivatePort: uint16(p),
Type: port.Proto(),
})
continue
@ -530,8 +530,8 @@ func (daemon *Daemon) transformContainer(container *container.Container, ctx *li
return nil, err
}
newC.Ports = append(newC.Ports, types.Port{
PrivatePort: p,
PublicPort: h,
PrivatePort: uint16(p),
PublicPort: uint16(h),
Type: port.Proto(),
IP: binding.HostIP,
})

9
hack/generate-swagger-api.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
set -eu
swagger generate model -f api/swagger.yaml \
-t api -m types --skip-validator \
-n Volume \
-n Port \
-n ImageSummary \
-n Plugin -n PluginDevice -n PluginMount -n PluginEnv -n PluginInterfaceType

View File

@ -3,7 +3,7 @@
source "${MAKEDIR}/.validate"
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/' || true) )
unset IFS
errors=()

View File

@ -18,7 +18,7 @@ func (s *DockerSuite) TestAPIImagesFilter(c *check.C) {
for _, n := range []string{name, name2, name3} {
dockerCmd(c, "tag", "busybox", n)
}
type image types.Image
type image types.ImageSummary
getImages := func(filter string) []image {
v := url.Values{}
v.Set("filter", filter)