github.com/nullne/docker@v1.13.0-rc1/api/types/types.go (about)

     1  package types
     2  
     3  import (
     4  	"io"
     5  	"os"
     6  	"time"
     7  
     8  	"github.com/docker/docker/api/types/container"
     9  	"github.com/docker/docker/api/types/filters"
    10  	"github.com/docker/docker/api/types/mount"
    11  	"github.com/docker/docker/api/types/network"
    12  	"github.com/docker/docker/api/types/registry"
    13  	"github.com/docker/docker/api/types/swarm"
    14  	"github.com/docker/go-connections/nat"
    15  )
    16  
    17  // ContainerChange contains response of Remote API:
    18  // GET "/containers/{name:.*}/changes"
    19  type ContainerChange struct {
    20  	Kind int
    21  	Path string
    22  }
    23  
    24  // ImageHistory contains response of Remote API:
    25  // GET "/images/{name:.*}/history"
    26  type ImageHistory struct {
    27  	ID        string `json:"Id"`
    28  	Created   int64
    29  	CreatedBy string
    30  	Tags      []string
    31  	Size      int64
    32  	Comment   string
    33  }
    34  
    35  // ImageDelete contains response of Remote API:
    36  // DELETE "/images/{name:.*}"
    37  type ImageDelete struct {
    38  	Untagged string `json:",omitempty"`
    39  	Deleted  string `json:",omitempty"`
    40  }
    41  
    42  // GraphDriverData returns Image's graph driver config info
    43  // when calling inspect command
    44  type GraphDriverData struct {
    45  	Name string
    46  	Data map[string]string
    47  }
    48  
    49  // RootFS returns Image's RootFS description including the layer IDs.
    50  type RootFS struct {
    51  	Type      string
    52  	Layers    []string `json:",omitempty"`
    53  	BaseLayer string   `json:",omitempty"`
    54  }
    55  
    56  // ImageInspect contains response of Remote API:
    57  // GET "/images/{name:.*}/json"
    58  type ImageInspect struct {
    59  	ID              string `json:"Id"`
    60  	RepoTags        []string
    61  	RepoDigests     []string
    62  	Parent          string
    63  	Comment         string
    64  	Created         string
    65  	Container       string
    66  	ContainerConfig *container.Config
    67  	DockerVersion   string
    68  	Author          string
    69  	Config          *container.Config
    70  	Architecture    string
    71  	Os              string
    72  	OsVersion       string `json:",omitempty"`
    73  	Size            int64
    74  	VirtualSize     int64
    75  	GraphDriver     GraphDriverData
    76  	RootFS          RootFS
    77  }
    78  
    79  // Container contains response of Remote API:
    80  // GET "/containers/json"
    81  type Container struct {
    82  	ID         string `json:"Id"`
    83  	Names      []string
    84  	Image      string
    85  	ImageID    string
    86  	Command    string
    87  	Created    int64
    88  	Ports      []Port
    89  	SizeRw     int64 `json:",omitempty"`
    90  	SizeRootFs int64 `json:",omitempty"`
    91  	Labels     map[string]string
    92  	State      string
    93  	Status     string
    94  	HostConfig struct {
    95  		NetworkMode string `json:",omitempty"`
    96  	}
    97  	NetworkSettings *SummaryNetworkSettings
    98  	Mounts          []MountPoint
    99  }
   100  
   101  // CopyConfig contains request body of Remote API:
   102  // POST "/containers/"+containerID+"/copy"
   103  type CopyConfig struct {
   104  	Resource string
   105  }
   106  
   107  // ContainerPathStat is used to encode the header from
   108  // GET "/containers/{name:.*}/archive"
   109  // "Name" is the file or directory name.
   110  type ContainerPathStat struct {
   111  	Name       string      `json:"name"`
   112  	Size       int64       `json:"size"`
   113  	Mode       os.FileMode `json:"mode"`
   114  	Mtime      time.Time   `json:"mtime"`
   115  	LinkTarget string      `json:"linkTarget"`
   116  }
   117  
   118  // ContainerStats contains response of Remote API:
   119  // GET "/stats"
   120  type ContainerStats struct {
   121  	Body   io.ReadCloser `json:"body"`
   122  	OSType string        `json:"ostype"`
   123  }
   124  
   125  // ContainerProcessList contains response of Remote API:
   126  // GET "/containers/{name:.*}/top"
   127  type ContainerProcessList struct {
   128  	Processes [][]string
   129  	Titles    []string
   130  }
   131  
   132  // Ping contains response of Remote API:
   133  // GET "/_ping"
   134  type Ping struct {
   135  	APIVersion   string
   136  	Experimental bool
   137  }
   138  
   139  // Version contains response of Remote API:
   140  // GET "/version"
   141  type Version struct {
   142  	Version       string
   143  	APIVersion    string `json:"ApiVersion"`
   144  	MinAPIVersion string `json:"MinAPIVersion,omitempty"`
   145  	GitCommit     string
   146  	GoVersion     string
   147  	Os            string
   148  	Arch          string
   149  	KernelVersion string `json:",omitempty"`
   150  	Experimental  bool   `json:",omitempty"`
   151  	BuildTime     string `json:",omitempty"`
   152  }
   153  
   154  // Commit records a external tool actual commit id version along the
   155  // one expect by dockerd as set at build time
   156  type Commit struct {
   157  	ID       string
   158  	Expected string
   159  }
   160  
   161  // InfoBase contains the base response of Remote API:
   162  // GET "/info"
   163  type InfoBase struct {
   164  	ID                 string
   165  	Containers         int
   166  	ContainersRunning  int
   167  	ContainersPaused   int
   168  	ContainersStopped  int
   169  	Images             int
   170  	Driver             string
   171  	DriverStatus       [][2]string
   172  	SystemStatus       [][2]string
   173  	Plugins            PluginsInfo
   174  	MemoryLimit        bool
   175  	SwapLimit          bool
   176  	KernelMemory       bool
   177  	CPUCfsPeriod       bool `json:"CpuCfsPeriod"`
   178  	CPUCfsQuota        bool `json:"CpuCfsQuota"`
   179  	CPUShares          bool
   180  	CPUSet             bool
   181  	IPv4Forwarding     bool
   182  	BridgeNfIptables   bool
   183  	BridgeNfIP6tables  bool `json:"BridgeNfIp6tables"`
   184  	Debug              bool
   185  	NFd                int
   186  	OomKillDisable     bool
   187  	NGoroutines        int
   188  	SystemTime         string
   189  	LoggingDriver      string
   190  	CgroupDriver       string
   191  	NEventsListener    int
   192  	KernelVersion      string
   193  	OperatingSystem    string
   194  	OSType             string
   195  	Architecture       string
   196  	IndexServerAddress string
   197  	RegistryConfig     *registry.ServiceConfig
   198  	NCPU               int
   199  	MemTotal           int64
   200  	DockerRootDir      string
   201  	HTTPProxy          string `json:"HttpProxy"`
   202  	HTTPSProxy         string `json:"HttpsProxy"`
   203  	NoProxy            string
   204  	Name               string
   205  	Labels             []string
   206  	ExperimentalBuild  bool
   207  	ServerVersion      string
   208  	ClusterStore       string
   209  	ClusterAdvertise   string
   210  	Runtimes           map[string]Runtime
   211  	DefaultRuntime     string
   212  	Swarm              swarm.Info
   213  	// LiveRestoreEnabled determines whether containers should be kept
   214  	// running when the daemon is shutdown or upon daemon start if
   215  	// running containers are detected
   216  	LiveRestoreEnabled bool
   217  	Isolation          container.Isolation
   218  	InitBinary         string
   219  	ContainerdCommit   Commit
   220  	RuncCommit         Commit
   221  	InitCommit         Commit
   222  }
   223  
   224  // SecurityOpt holds key/value pair about a security option
   225  type SecurityOpt struct {
   226  	Key, Value string
   227  }
   228  
   229  // Info contains response of Remote API:
   230  // GET "/info"
   231  type Info struct {
   232  	*InfoBase
   233  	SecurityOptions []SecurityOpt
   234  }
   235  
   236  // PluginsInfo is a temp struct holding Plugins name
   237  // registered with docker daemon. It is used by Info struct
   238  type PluginsInfo struct {
   239  	// List of Volume plugins registered
   240  	Volume []string
   241  	// List of Network plugins registered
   242  	Network []string
   243  	// List of Authorization plugins registered
   244  	Authorization []string
   245  }
   246  
   247  // ExecStartCheck is a temp struct used by execStart
   248  // Config fields is part of ExecConfig in runconfig package
   249  type ExecStartCheck struct {
   250  	// ExecStart will first check if it's detached
   251  	Detach bool
   252  	// Check if there's a tty
   253  	Tty bool
   254  }
   255  
   256  // HealthcheckResult stores information about a single run of a healthcheck probe
   257  type HealthcheckResult struct {
   258  	Start    time.Time // Start is the time this check started
   259  	End      time.Time // End is the time this check ended
   260  	ExitCode int       // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe
   261  	Output   string    // Output from last check
   262  }
   263  
   264  // Health states
   265  const (
   266  	NoHealthcheck = "none"      // Indicates there is no healthcheck
   267  	Starting      = "starting"  // Starting indicates that the container is not yet ready
   268  	Healthy       = "healthy"   // Healthy indicates that the container is running correctly
   269  	Unhealthy     = "unhealthy" // Unhealthy indicates that the container has a problem
   270  )
   271  
   272  // Health stores information about the container's healthcheck results
   273  type Health struct {
   274  	Status        string               // Status is one of Starting, Healthy or Unhealthy
   275  	FailingStreak int                  // FailingStreak is the number of consecutive failures
   276  	Log           []*HealthcheckResult // Log contains the last few results (oldest first)
   277  }
   278  
   279  // ContainerState stores container's running state
   280  // it's part of ContainerJSONBase and will return by "inspect" command
   281  type ContainerState struct {
   282  	Status     string
   283  	Running    bool
   284  	Paused     bool
   285  	Restarting bool
   286  	OOMKilled  bool
   287  	Dead       bool
   288  	Pid        int
   289  	ExitCode   int
   290  	Error      string
   291  	StartedAt  string
   292  	FinishedAt string
   293  	Health     *Health `json:",omitempty"`
   294  }
   295  
   296  // ContainerNode stores information about the node that a container
   297  // is running on.  It's only available in Docker Swarm
   298  type ContainerNode struct {
   299  	ID        string
   300  	IPAddress string `json:"IP"`
   301  	Addr      string
   302  	Name      string
   303  	Cpus      int
   304  	Memory    int64
   305  	Labels    map[string]string
   306  }
   307  
   308  // ContainerJSONBase contains response of Remote API:
   309  // GET "/containers/{name:.*}/json"
   310  type ContainerJSONBase struct {
   311  	ID              string `json:"Id"`
   312  	Created         string
   313  	Path            string
   314  	Args            []string
   315  	State           *ContainerState
   316  	Image           string
   317  	ResolvConfPath  string
   318  	HostnamePath    string
   319  	HostsPath       string
   320  	LogPath         string
   321  	Node            *ContainerNode `json:",omitempty"`
   322  	Name            string
   323  	RestartCount    int
   324  	Driver          string
   325  	MountLabel      string
   326  	ProcessLabel    string
   327  	AppArmorProfile string
   328  	ExecIDs         []string
   329  	HostConfig      *container.HostConfig
   330  	GraphDriver     GraphDriverData
   331  	SizeRw          *int64 `json:",omitempty"`
   332  	SizeRootFs      *int64 `json:",omitempty"`
   333  }
   334  
   335  // ContainerJSON is newly used struct along with MountPoint
   336  type ContainerJSON struct {
   337  	*ContainerJSONBase
   338  	Mounts          []MountPoint
   339  	Config          *container.Config
   340  	NetworkSettings *NetworkSettings
   341  }
   342  
   343  // NetworkSettings exposes the network settings in the api
   344  type NetworkSettings struct {
   345  	NetworkSettingsBase
   346  	DefaultNetworkSettings
   347  	Networks map[string]*network.EndpointSettings
   348  }
   349  
   350  // SummaryNetworkSettings provides a summary of container's networks
   351  // in /containers/json
   352  type SummaryNetworkSettings struct {
   353  	Networks map[string]*network.EndpointSettings
   354  }
   355  
   356  // NetworkSettingsBase holds basic information about networks
   357  type NetworkSettingsBase struct {
   358  	Bridge                 string      // Bridge is the Bridge name the network uses(e.g. `docker0`)
   359  	SandboxID              string      // SandboxID uniquely represents a container's network stack
   360  	HairpinMode            bool        // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
   361  	LinkLocalIPv6Address   string      // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix
   362  	LinkLocalIPv6PrefixLen int         // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address
   363  	Ports                  nat.PortMap // Ports is a collection of PortBinding indexed by Port
   364  	SandboxKey             string      // SandboxKey identifies the sandbox
   365  	SecondaryIPAddresses   []network.Address
   366  	SecondaryIPv6Addresses []network.Address
   367  }
   368  
   369  // DefaultNetworkSettings holds network information
   370  // during the 2 release deprecation period.
   371  // It will be removed in Docker 1.11.
   372  type DefaultNetworkSettings struct {
   373  	EndpointID          string // EndpointID uniquely represents a service endpoint in a Sandbox
   374  	Gateway             string // Gateway holds the gateway address for the network
   375  	GlobalIPv6Address   string // GlobalIPv6Address holds network's global IPv6 address
   376  	GlobalIPv6PrefixLen int    // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
   377  	IPAddress           string // IPAddress holds the IPv4 address for the network
   378  	IPPrefixLen         int    // IPPrefixLen represents mask length of network's IPv4 address
   379  	IPv6Gateway         string // IPv6Gateway holds gateway address specific for IPv6
   380  	MacAddress          string // MacAddress holds the MAC address for the network
   381  }
   382  
   383  // MountPoint represents a mount point configuration inside the container.
   384  // This is used for reporting the mountpoints in use by a container.
   385  type MountPoint struct {
   386  	Type        mount.Type `json:",omitempty"`
   387  	Name        string     `json:",omitempty"`
   388  	Source      string
   389  	Destination string
   390  	Driver      string `json:",omitempty"`
   391  	Mode        string
   392  	RW          bool
   393  	Propagation mount.Propagation
   394  }
   395  
   396  // NetworkResource is the body of the "get network" http response message
   397  type NetworkResource struct {
   398  	Name       string                      // Name is the requested name of the network
   399  	ID         string                      `json:"Id"` // ID uniquely identifies a network on a single machine
   400  	Created    time.Time                   // Created is the time the network created
   401  	Scope      string                      // Scope describes the level at which the network exists (e.g. `global` for cluster-wide or `local` for machine level)
   402  	Driver     string                      // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
   403  	EnableIPv6 bool                        // EnableIPv6 represents whether to enable IPv6
   404  	IPAM       network.IPAM                // IPAM is the network's IP Address Management
   405  	Internal   bool                        // Internal represents if the network is used internal only
   406  	Attachable bool                        // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
   407  	Containers map[string]EndpointResource // Containers contains endpoints belonging to the network
   408  	Options    map[string]string           // Options holds the network specific options to use for when creating the network
   409  	Labels     map[string]string           // Labels holds metadata specific to the network being created
   410  	Peers      []network.PeerInfo          `json:",omitempty"` // List of peer nodes for an overlay network
   411  }
   412  
   413  // EndpointResource contains network resources allocated and used for a container in a network
   414  type EndpointResource struct {
   415  	Name        string
   416  	EndpointID  string
   417  	MacAddress  string
   418  	IPv4Address string
   419  	IPv6Address string
   420  }
   421  
   422  // NetworkCreate is the expected body of the "create network" http request message
   423  type NetworkCreate struct {
   424  	CheckDuplicate bool
   425  	Driver         string
   426  	EnableIPv6     bool
   427  	IPAM           *network.IPAM
   428  	Internal       bool
   429  	Attachable     bool
   430  	Options        map[string]string
   431  	Labels         map[string]string
   432  }
   433  
   434  // NetworkCreateRequest is the request message sent to the server for network create call.
   435  type NetworkCreateRequest struct {
   436  	NetworkCreate
   437  	Name string
   438  }
   439  
   440  // NetworkCreateResponse is the response message sent by the server for network create call
   441  type NetworkCreateResponse struct {
   442  	ID      string `json:"Id"`
   443  	Warning string
   444  }
   445  
   446  // NetworkConnect represents the data to be used to connect a container to the network
   447  type NetworkConnect struct {
   448  	Container      string
   449  	EndpointConfig *network.EndpointSettings `json:",omitempty"`
   450  }
   451  
   452  // NetworkDisconnect represents the data to be used to disconnect a container from the network
   453  type NetworkDisconnect struct {
   454  	Container string
   455  	Force     bool
   456  }
   457  
   458  // Checkpoint represents the details of a checkpoint
   459  type Checkpoint struct {
   460  	Name string // Name is the name of the checkpoint
   461  }
   462  
   463  // Runtime describes an OCI runtime
   464  type Runtime struct {
   465  	Path string   `json:"path"`
   466  	Args []string `json:"runtimeArgs,omitempty"`
   467  }
   468  
   469  // DiskUsage contains response of Remote API:
   470  // GET "/system/df"
   471  type DiskUsage struct {
   472  	LayersSize int64
   473  	Images     []*ImageSummary
   474  	Containers []*Container
   475  	Volumes    []*Volume
   476  }
   477  
   478  // ImagesPruneConfig contains the configuration for Remote API:
   479  // POST "/images/prune"
   480  type ImagesPruneConfig struct {
   481  	DanglingOnly bool
   482  }
   483  
   484  // ContainersPruneConfig contains the configuration for Remote API:
   485  // POST "/images/prune"
   486  type ContainersPruneConfig struct {
   487  }
   488  
   489  // VolumesPruneConfig contains the configuration for Remote API:
   490  // POST "/images/prune"
   491  type VolumesPruneConfig struct {
   492  }
   493  
   494  // NetworksPruneConfig contains the configuration for Remote API:
   495  // POST "/networks/prune"
   496  type NetworksPruneConfig struct {
   497  }
   498  
   499  // ContainersPruneReport contains the response for Remote API:
   500  // POST "/containers/prune"
   501  type ContainersPruneReport struct {
   502  	ContainersDeleted []string
   503  	SpaceReclaimed    uint64
   504  }
   505  
   506  // VolumesPruneReport contains the response for Remote API:
   507  // POST "/volumes/prune"
   508  type VolumesPruneReport struct {
   509  	VolumesDeleted []string
   510  	SpaceReclaimed uint64
   511  }
   512  
   513  // ImagesPruneReport contains the response for Remote API:
   514  // POST "/images/prune"
   515  type ImagesPruneReport struct {
   516  	ImagesDeleted  []ImageDelete
   517  	SpaceReclaimed uint64
   518  }
   519  
   520  // NetworksPruneReport contains the response for Remote API:
   521  // POST "/networks/prune"
   522  type NetworksPruneReport struct {
   523  	NetworksDeleted []string
   524  }
   525  
   526  // SecretCreateResponse contains the information returned to a client
   527  // on the creation of a new secret.
   528  type SecretCreateResponse struct {
   529  	// ID is the id of the created secret.
   530  	ID string
   531  }
   532  
   533  // SecretListOptions holds parameters to list secrets
   534  type SecretListOptions struct {
   535  	Filters filters.Args
   536  }