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