Merge pull request #27117 from dnephin/swagger-gen
Add swagger.yaml and generate a few types from the spec
This commit is contained in:
commit
3c385b9f6b
6
Makefile
6
Makefile
|
@ -137,3 +137,9 @@ validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isol
|
||||||
|
|
||||||
win: build ## cross build the binary for windows
|
win: build ## cross build the binary for windows
|
||||||
$(DOCKER_RUN_DOCKER) hack/make.sh win
|
$(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
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
// Common constants for daemon and client.
|
// Common constants for daemon and client.
|
||||||
const (
|
const (
|
||||||
// Version of Current REST API
|
// DefaultVersion of Current REST API
|
||||||
DefaultVersion string = "1.25"
|
DefaultVersion string = "1.25"
|
||||||
|
|
||||||
// MinVersion represents Minimum REST API version supported
|
// 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'
|
// it's used by command 'docker ps'
|
||||||
func DisplayablePorts(ports []types.Port) string {
|
func DisplayablePorts(ports []types.Port) string {
|
||||||
type portGroup struct {
|
type portGroup struct {
|
||||||
first int
|
first uint16
|
||||||
last int
|
last uint16
|
||||||
}
|
}
|
||||||
groupMap := make(map[string]*portGroup)
|
groupMap := make(map[string]*portGroup)
|
||||||
var result []string
|
var result []string
|
||||||
|
@ -99,7 +99,7 @@ func DisplayablePorts(ports []types.Port) string {
|
||||||
return strings.Join(result, ", ")
|
return strings.Join(result, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func formGroup(key string, start, last int) string {
|
func formGroup(key string, start, last uint16) string {
|
||||||
parts := strings.Split(key, "/")
|
parts := strings.Split(key, "/")
|
||||||
groupType := parts[0]
|
groupType := parts[0]
|
||||||
var ip string
|
var ip string
|
||||||
|
@ -107,7 +107,7 @@ func formGroup(key string, start, last int) string {
|
||||||
ip = parts[0]
|
ip = parts[0]
|
||||||
groupType = parts[1]
|
groupType = parts[1]
|
||||||
}
|
}
|
||||||
group := strconv.Itoa(start)
|
group := strconv.Itoa(int(start))
|
||||||
if start != last {
|
if start != last {
|
||||||
group = fmt.Sprintf("%s-%d", group, last)
|
group = fmt.Sprintf("%s-%d", group, last)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ type containerBackend interface {
|
||||||
type imageBackend interface {
|
type imageBackend interface {
|
||||||
ImageDelete(imageRef string, force, prune bool) ([]types.ImageDelete, error)
|
ImageDelete(imageRef string, force, prune bool) ([]types.ImageDelete, error)
|
||||||
ImageHistory(imageName string) ([]*types.ImageHistory, 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)
|
LookupImage(name string) (*types.ImageInspect, error)
|
||||||
TagImage(imageName, repository, tag string) error
|
TagImage(imageName, repository, tag string) error
|
||||||
ImagesPrune(config *types.ImagesPruneConfig) (*types.ImagesPruneReport, error)
|
ImagesPrune(config *types.ImagesPruneConfig) (*types.ImagesPruneReport, error)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -314,3 +314,12 @@ type TaskListOptions struct {
|
||||||
type PluginRemoveOptions struct {
|
type PluginRemoveOptions struct {
|
||||||
Force bool
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -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"`
|
||||||
|
}
|
|
@ -1,168 +1,163 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
// This file was generated by the swagger tool.
|
||||||
"encoding/json"
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PluginInstallOptions holds parameters to install a plugin.
|
// Plugin A plugin for the Remote API
|
||||||
type PluginInstallOptions struct {
|
// swagger:model Plugin
|
||||||
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
|
|
||||||
type Plugin struct {
|
type Plugin struct {
|
||||||
ID string `json:"Id,omitempty"`
|
|
||||||
Name string
|
// config
|
||||||
Tag string
|
// Required: true
|
||||||
// Enabled is true when the plugin is running, is false when the plugin is not running, only installed.
|
Config PluginConfig `json:"Config"`
|
||||||
Enabled bool
|
|
||||||
Config PluginConfig
|
// True when the plugin is running. False when the plugin is not running, only installed.
|
||||||
Manifest PluginManifest
|
// 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
|
// PluginConfig Settings that can be modified by users.
|
||||||
type PluginsListResponse []*Plugin
|
// swagger:model PluginConfig
|
||||||
|
type PluginConfig struct {
|
||||||
|
|
||||||
const (
|
// args
|
||||||
authzDriver = "AuthzDriver"
|
// Required: true
|
||||||
graphDriver = "GraphDriver"
|
Args []string `json:"Args"`
|
||||||
ipamDriver = "IpamDriver"
|
|
||||||
networkDriver = "NetworkDriver"
|
|
||||||
volumeDriver = "VolumeDriver"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PluginInterfaceType represents a type that a plugin implements.
|
// devices
|
||||||
type PluginInterfaceType struct {
|
// Required: true
|
||||||
Prefix string // This is always "docker"
|
Devices []PluginDevice `json:"Devices"`
|
||||||
Capability string // Capability should be validated against the above list.
|
|
||||||
Version string // Plugin API version. Depends on the capability
|
// env
|
||||||
|
// Required: true
|
||||||
|
Env []string `json:"Env"`
|
||||||
|
|
||||||
|
// mounts
|
||||||
|
// Required: true
|
||||||
|
Mounts []PluginMount `json:"Mounts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshaler for PluginInterfaceType
|
// PluginManifest The manifest of a plugin.
|
||||||
func (t *PluginInterfaceType) UnmarshalJSON(p []byte) error {
|
// swagger:model PluginManifest
|
||||||
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
|
|
||||||
type PluginManifest struct {
|
type PluginManifest struct {
|
||||||
ManifestVersion string
|
|
||||||
Description string
|
// args
|
||||||
Documentation string
|
// Required: true
|
||||||
Interface PluginInterface
|
Args PluginManifestArgs `json:"Args"`
|
||||||
Entrypoint []string
|
|
||||||
Workdir string
|
// capabilities
|
||||||
User PluginUser `json:",omitempty"`
|
// Required: true
|
||||||
Network PluginNetwork
|
Capabilities []string `json:"Capabilities"`
|
||||||
Capabilities []string
|
|
||||||
Mounts []PluginMount
|
// description
|
||||||
Devices []PluginDevice
|
// Required: true
|
||||||
Env []PluginEnv
|
Description string `json:"Description"`
|
||||||
Args PluginArgs
|
|
||||||
|
// 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
|
// PluginManifestArgs plugin manifest args
|
||||||
// upon installing a plugin.
|
// swagger:model PluginManifestArgs
|
||||||
type PluginPrivilege struct {
|
type PluginManifestArgs struct {
|
||||||
Name string
|
|
||||||
Description string
|
// description
|
||||||
Value []string
|
// 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
|
// PluginManifestInterface The interface between Docker and the plugin
|
||||||
type PluginPrivileges []PluginPrivilege
|
// 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"`
|
||||||
|
}
|
||||||
|
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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
|
|
@ -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"`
|
||||||
|
}
|
|
@ -86,21 +86,6 @@ type ImageDelete struct {
|
||||||
Deleted string `json:",omitempty"`
|
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
|
// GraphDriverData returns Image's graph driver config info
|
||||||
// when calling inspect command
|
// when calling inspect command
|
||||||
type GraphDriverData struct {
|
type GraphDriverData struct {
|
||||||
|
@ -138,15 +123,6 @@ type ImageInspect struct {
|
||||||
RootFS RootFS
|
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:
|
// Container contains response of Remote API:
|
||||||
// GET "/containers/json"
|
// GET "/containers/json"
|
||||||
type Container struct {
|
type Container struct {
|
||||||
|
@ -433,24 +409,6 @@ type MountPoint struct {
|
||||||
Propagation mount.Propagation
|
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:
|
// VolumesListResponse contains the response for the remote API:
|
||||||
// GET "/volumes"
|
// GET "/volumes"
|
||||||
type VolumesListResponse struct {
|
type VolumesListResponse struct {
|
||||||
|
@ -543,7 +501,7 @@ type Runtime struct {
|
||||||
// GET "/system/df"
|
// GET "/system/df"
|
||||||
type DiskUsage struct {
|
type DiskUsage struct {
|
||||||
LayersSize int64
|
LayersSize int64
|
||||||
Images []*Image
|
Images []*ImageSummary
|
||||||
Containers []*Container
|
Containers []*Container
|
||||||
Volumes []*Volume
|
Volumes []*Volume
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"`
|
||||||
|
}
|
|
@ -31,7 +31,7 @@ type DiskUsageContext struct {
|
||||||
Context
|
Context
|
||||||
Verbose bool
|
Verbose bool
|
||||||
LayersSize int64
|
LayersSize int64
|
||||||
Images []*types.Image
|
Images []*types.ImageSummary
|
||||||
Containers []*types.Container
|
Containers []*types.Container
|
||||||
Volumes []*types.Volume
|
Volumes []*types.Volume
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ func (ctx *DiskUsageContext) Write() {
|
||||||
type diskUsageImagesContext struct {
|
type diskUsageImagesContext struct {
|
||||||
HeaderContext
|
HeaderContext
|
||||||
totalSize int64
|
totalSize int64
|
||||||
images []*types.Image
|
images []*types.ImageSummary
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *diskUsageImagesContext) Type() string {
|
func (c *diskUsageImagesContext) Type() string {
|
||||||
|
|
|
@ -26,7 +26,7 @@ type ImageContext struct {
|
||||||
Digest bool
|
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>"
|
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
|
// 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 {
|
render := func(format func(subContext subContext) error) error {
|
||||||
return imageFormat(ctx, images, format)
|
return imageFormat(ctx, images, format)
|
||||||
}
|
}
|
||||||
return ctx.Write(&imageContext{}, render)
|
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 {
|
for _, image := range images {
|
||||||
images := []*imageContext{}
|
images := []*imageContext{}
|
||||||
if isDangling(image) {
|
if isDangling(image) {
|
||||||
|
@ -184,7 +184,7 @@ func imageFormat(ctx ImageContext, images []types.Image, format func(subContext
|
||||||
type imageContext struct {
|
type imageContext struct {
|
||||||
HeaderContext
|
HeaderContext
|
||||||
trunc bool
|
trunc bool
|
||||||
i types.Image
|
i types.ImageSummary
|
||||||
repo string
|
repo string
|
||||||
tag string
|
tag string
|
||||||
digest string
|
digest string
|
||||||
|
|
|
@ -24,36 +24,36 @@ func TestImageContext(t *testing.T) {
|
||||||
call func() string
|
call func() string
|
||||||
}{
|
}{
|
||||||
{imageContext{
|
{imageContext{
|
||||||
i: types.Image{ID: imageID},
|
i: types.ImageSummary{ID: imageID},
|
||||||
trunc: true,
|
trunc: true,
|
||||||
}, stringid.TruncateID(imageID), imageIDHeader, ctx.ID},
|
}, stringid.TruncateID(imageID), imageIDHeader, ctx.ID},
|
||||||
{imageContext{
|
{imageContext{
|
||||||
i: types.Image{ID: imageID},
|
i: types.ImageSummary{ID: imageID},
|
||||||
trunc: false,
|
trunc: false,
|
||||||
}, imageID, imageIDHeader, ctx.ID},
|
}, imageID, imageIDHeader, ctx.ID},
|
||||||
{imageContext{
|
{imageContext{
|
||||||
i: types.Image{Size: 10, VirtualSize: 10},
|
i: types.ImageSummary{Size: 10, VirtualSize: 10},
|
||||||
trunc: true,
|
trunc: true,
|
||||||
}, "10 B", sizeHeader, ctx.Size},
|
}, "10 B", sizeHeader, ctx.Size},
|
||||||
{imageContext{
|
{imageContext{
|
||||||
i: types.Image{Created: unix},
|
i: types.ImageSummary{Created: unix},
|
||||||
trunc: true,
|
trunc: true,
|
||||||
}, time.Unix(unix, 0).String(), createdAtHeader, ctx.CreatedAt},
|
}, time.Unix(unix, 0).String(), createdAtHeader, ctx.CreatedAt},
|
||||||
// FIXME
|
// FIXME
|
||||||
// {imageContext{
|
// {imageContext{
|
||||||
// i: types.Image{Created: unix},
|
// i: types.ImageSummary{Created: unix},
|
||||||
// trunc: true,
|
// trunc: true,
|
||||||
// }, units.HumanDuration(time.Unix(unix, 0)), createdSinceHeader, ctx.CreatedSince},
|
// }, units.HumanDuration(time.Unix(unix, 0)), createdSinceHeader, ctx.CreatedSince},
|
||||||
{imageContext{
|
{imageContext{
|
||||||
i: types.Image{},
|
i: types.ImageSummary{},
|
||||||
repo: "busybox",
|
repo: "busybox",
|
||||||
}, "busybox", repositoryHeader, ctx.Repository},
|
}, "busybox", repositoryHeader, ctx.Repository},
|
||||||
{imageContext{
|
{imageContext{
|
||||||
i: types.Image{},
|
i: types.ImageSummary{},
|
||||||
tag: "latest",
|
tag: "latest",
|
||||||
}, "latest", tagHeader, ctx.Tag},
|
}, "latest", tagHeader, ctx.Tag},
|
||||||
{imageContext{
|
{imageContext{
|
||||||
i: types.Image{},
|
i: types.ImageSummary{},
|
||||||
digest: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a",
|
digest: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a",
|
||||||
}, "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a", digestHeader, ctx.Digest},
|
}, "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a", digestHeader, ctx.Digest},
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ image_id: imageID3
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testcase := range cases {
|
for _, testcase := range cases {
|
||||||
images := []types.Image{
|
images := []types.ImageSummary{
|
||||||
{ID: "imageID1", RepoTags: []string{"image:tag1"}, RepoDigests: []string{"image@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"}, Created: unixTime},
|
{ID: "imageID1", RepoTags: []string{"image:tag1"}, RepoDigests: []string{"image@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"}, Created: unixTime},
|
||||||
{ID: "imageID2", RepoTags: []string{"image:tag2"}, Created: unixTime},
|
{ID: "imageID2", RepoTags: []string{"image:tag2"}, Created: unixTime},
|
||||||
{ID: "imageID3", RepoTags: []string{"<none>:<none>"}, RepoDigests: []string{"<none>@<none>"}, 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) {
|
func TestImageContextWriteWithNoImage(t *testing.T) {
|
||||||
out := bytes.NewBufferString("")
|
out := bytes.NewBufferString("")
|
||||||
images := []types.Image{}
|
images := []types.ImageSummary{}
|
||||||
|
|
||||||
contexts := []struct {
|
contexts := []struct {
|
||||||
context ImageContext
|
context ImageContext
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImageList returns a list of images in the docker host.
|
// ImageList returns a list of images in the docker host.
|
||||||
func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) {
|
func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) {
|
||||||
var images []types.Image
|
var images []types.ImageSummary
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
|
|
||||||
if options.Filters.Len() > 0 {
|
if options.Filters.Len() > 0 {
|
||||||
|
|
|
@ -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)
|
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",
|
ID: "image_id2",
|
||||||
},
|
},
|
||||||
|
|
|
@ -71,7 +71,7 @@ type ImageAPIClient interface {
|
||||||
ImageHistory(ctx context.Context, image string) ([]types.ImageHistory, error)
|
ImageHistory(ctx context.Context, image string) ([]types.ImageHistory, error)
|
||||||
ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, 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)
|
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)
|
ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
|
||||||
ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, 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)
|
ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error)
|
||||||
|
|
|
@ -61,7 +61,7 @@ func (daemon *Daemon) SystemDiskUsage() (*types.DiskUsage, error) {
|
||||||
logrus.Warnf("failed to determine size of volume %v", name)
|
logrus.Warnf("failed to determine size of volume %v", name)
|
||||||
sz = -1
|
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)
|
allVolumes = append(allVolumes, tv)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -22,7 +22,7 @@ var acceptedImageFilterTags = map[string]bool{
|
||||||
|
|
||||||
// byCreated is a temporary type used to sort a list of images by creation
|
// byCreated is a temporary type used to sort a list of images by creation
|
||||||
// time.
|
// time.
|
||||||
type byCreated []*types.Image
|
type byCreated []*types.ImageSummary
|
||||||
|
|
||||||
func (r byCreated) Len() int { return len(r) }
|
func (r byCreated) Len() int { return len(r) }
|
||||||
func (r byCreated) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
|
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
|
// 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
|
// named all controls whether all images in the graph are filtered, or just
|
||||||
// the heads.
|
// 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 (
|
var (
|
||||||
allImages map[image.ID]*image.Image
|
allImages map[image.ID]*image.Image
|
||||||
err error
|
err error
|
||||||
|
@ -83,8 +83,8 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
images := []*types.Image{}
|
images := []*types.ImageSummary{}
|
||||||
var imagesMap map[*image.Image]*types.Image
|
var imagesMap map[*image.Image]*types.ImageSummary
|
||||||
var layerRefs map[layer.ChainID]int
|
var layerRefs map[layer.ChainID]int
|
||||||
var allLayers map[layer.ChainID]layer.Layer
|
var allLayers map[layer.ChainID]layer.Layer
|
||||||
var allContainers []*container.Container
|
var allContainers []*container.Container
|
||||||
|
@ -181,7 +181,7 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs
|
||||||
if imagesMap == nil {
|
if imagesMap == nil {
|
||||||
allContainers = daemon.List()
|
allContainers = daemon.List()
|
||||||
allLayers = daemon.layerStore.Map()
|
allLayers = daemon.layerStore.Map()
|
||||||
imagesMap = make(map[*image.Image]*types.Image)
|
imagesMap = make(map[*image.Image]*types.ImageSummary)
|
||||||
layerRefs = make(map[layer.ChainID]int)
|
layerRefs = make(map[layer.ChainID]int)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,8 +241,8 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs
|
||||||
return images, nil
|
return images, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newImage(image *image.Image, virtualSize int64) *types.Image {
|
func newImage(image *image.Image, virtualSize int64) *types.ImageSummary {
|
||||||
newImage := new(types.Image)
|
newImage := new(types.ImageSummary)
|
||||||
newImage.ParentID = image.Parent.String()
|
newImage.ParentID = image.Parent.String()
|
||||||
newImage.ID = image.ID().String()
|
newImage.ID = image.ID().String()
|
||||||
newImage.Created = image.Created.Unix()
|
newImage.Created = image.Created.Unix()
|
||||||
|
|
|
@ -519,7 +519,7 @@ func (daemon *Daemon) transformContainer(container *container.Container, ctx *li
|
||||||
}
|
}
|
||||||
if len(bindings) == 0 {
|
if len(bindings) == 0 {
|
||||||
newC.Ports = append(newC.Ports, types.Port{
|
newC.Ports = append(newC.Ports, types.Port{
|
||||||
PrivatePort: p,
|
PrivatePort: uint16(p),
|
||||||
Type: port.Proto(),
|
Type: port.Proto(),
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
|
@ -530,8 +530,8 @@ func (daemon *Daemon) transformContainer(container *container.Container, ctx *li
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
newC.Ports = append(newC.Ports, types.Port{
|
newC.Ports = append(newC.Ports, types.Port{
|
||||||
PrivatePort: p,
|
PrivatePort: uint16(p),
|
||||||
PublicPort: h,
|
PublicPort: uint16(h),
|
||||||
Type: port.Proto(),
|
Type: port.Proto(),
|
||||||
IP: binding.HostIP,
|
IP: binding.HostIP,
|
||||||
})
|
})
|
||||||
|
|
|
@ -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
|
|
@ -3,7 +3,7 @@
|
||||||
source "${MAKEDIR}/.validate"
|
source "${MAKEDIR}/.validate"
|
||||||
|
|
||||||
IFS=$'\n'
|
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
|
unset IFS
|
||||||
|
|
||||||
errors=()
|
errors=()
|
||||||
|
|
|
@ -18,7 +18,7 @@ func (s *DockerSuite) TestAPIImagesFilter(c *check.C) {
|
||||||
for _, n := range []string{name, name2, name3} {
|
for _, n := range []string{name, name2, name3} {
|
||||||
dockerCmd(c, "tag", "busybox", n)
|
dockerCmd(c, "tag", "busybox", n)
|
||||||
}
|
}
|
||||||
type image types.Image
|
type image types.ImageSummary
|
||||||
getImages := func(filter string) []image {
|
getImages := func(filter string) []image {
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
v.Set("filter", filter)
|
v.Set("filter", filter)
|
||||||
|
|
Loading…
Reference in New Issue