types.go 16 KB

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