types.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. package types
  2. import (
  3. "os"
  4. "time"
  5. "github.com/docker/docker/api/types/network"
  6. "github.com/docker/docker/api/types/registry"
  7. "github.com/docker/docker/pkg/version"
  8. "github.com/docker/docker/runconfig"
  9. "github.com/docker/go-connections/nat"
  10. )
  11. // ContainerCreateResponse contains the information returned to a client on the
  12. // creation of a new container.
  13. type ContainerCreateResponse struct {
  14. // ID is the ID of the created container.
  15. ID string `json:"Id"`
  16. // Warnings are any warnings encountered during the creation of the container.
  17. Warnings []string `json:"Warnings"`
  18. }
  19. // ContainerExecCreateResponse contains response of Remote API:
  20. // POST "/containers/{name:.*}/exec"
  21. type ContainerExecCreateResponse struct {
  22. // ID is the exec ID.
  23. ID string `json:"Id"`
  24. }
  25. // AuthResponse contains response of Remote API:
  26. // POST "/auth"
  27. type AuthResponse struct {
  28. // Status is the authentication status
  29. Status string `json:"Status"`
  30. }
  31. // ContainerWaitResponse contains response of Remote API:
  32. // POST "/containers/"+containerID+"/wait"
  33. type ContainerWaitResponse struct {
  34. // StatusCode is the status code of the wait job
  35. StatusCode int `json:"StatusCode"`
  36. }
  37. // ContainerCommitResponse contains response of Remote API:
  38. // POST "/commit?container="+containerID
  39. type ContainerCommitResponse struct {
  40. ID string `json:"Id"`
  41. }
  42. // ContainerChange contains response of Remote API:
  43. // GET "/containers/{name:.*}/changes"
  44. type ContainerChange struct {
  45. Kind int
  46. Path string
  47. }
  48. // ImageHistory contains response of Remote API:
  49. // GET "/images/{name:.*}/history"
  50. type ImageHistory struct {
  51. ID string `json:"Id"`
  52. Created int64
  53. CreatedBy string
  54. Tags []string
  55. Size int64
  56. Comment string
  57. }
  58. // ImageDelete contains response of Remote API:
  59. // DELETE "/images/{name:.*}"
  60. type ImageDelete struct {
  61. Untagged string `json:",omitempty"`
  62. Deleted string `json:",omitempty"`
  63. }
  64. // Image contains response of Remote API:
  65. // GET "/images/json"
  66. type Image struct {
  67. ID string `json:"Id"`
  68. ParentID string `json:"ParentId"`
  69. RepoTags []string
  70. RepoDigests []string
  71. Created int64
  72. Size int64
  73. VirtualSize int64
  74. Labels map[string]string
  75. }
  76. // GraphDriverData returns Image's graph driver config info
  77. // when calling inspect command
  78. type GraphDriverData struct {
  79. Name string
  80. Data map[string]string
  81. }
  82. // ImageInspect contains response of Remote API:
  83. // GET "/images/{name:.*}/json"
  84. type ImageInspect struct {
  85. ID string `json:"Id"`
  86. RepoTags []string
  87. RepoDigests []string
  88. Parent string
  89. Comment string
  90. Created string
  91. Container string
  92. ContainerConfig *runconfig.Config
  93. DockerVersion string
  94. Author string
  95. Config *runconfig.Config
  96. Architecture string
  97. Os string
  98. Size int64
  99. VirtualSize int64
  100. GraphDriver GraphDriverData
  101. }
  102. // Port stores open ports info of container
  103. // e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"}
  104. type Port struct {
  105. IP string `json:",omitempty"`
  106. PrivatePort int
  107. PublicPort int `json:",omitempty"`
  108. Type string
  109. }
  110. // Container contains response of Remote API:
  111. // GET "/containers/json"
  112. type Container struct {
  113. ID string `json:"Id"`
  114. Names []string
  115. Image string
  116. ImageID string
  117. Command string
  118. Created int64
  119. Ports []Port
  120. SizeRw int64 `json:",omitempty"`
  121. SizeRootFs int64 `json:",omitempty"`
  122. Labels map[string]string
  123. Status string
  124. HostConfig struct {
  125. NetworkMode string `json:",omitempty"`
  126. }
  127. NetworkSettings *SummaryNetworkSettings
  128. }
  129. // CopyConfig contains request body of Remote API:
  130. // POST "/containers/"+containerID+"/copy"
  131. type CopyConfig struct {
  132. Resource string
  133. }
  134. // ContainerPathStat is used to encode the header from
  135. // GET "/containers/{name:.*}/archive"
  136. // "Name" is the file or directory name.
  137. type ContainerPathStat struct {
  138. Name string `json:"name"`
  139. Size int64 `json:"size"`
  140. Mode os.FileMode `json:"mode"`
  141. Mtime time.Time `json:"mtime"`
  142. LinkTarget string `json:"linkTarget"`
  143. }
  144. // ContainerProcessList contains response of Remote API:
  145. // GET "/containers/{name:.*}/top"
  146. type ContainerProcessList struct {
  147. Processes [][]string
  148. Titles []string
  149. }
  150. // Version contains response of Remote API:
  151. // GET "/version"
  152. type Version struct {
  153. Version string
  154. APIVersion version.Version `json:"ApiVersion"`
  155. GitCommit string
  156. GoVersion string
  157. Os string
  158. Arch string
  159. KernelVersion string `json:",omitempty"`
  160. Experimental bool `json:",omitempty"`
  161. BuildTime string `json:",omitempty"`
  162. }
  163. // Info contains response of Remote API:
  164. // GET "/info"
  165. type Info struct {
  166. ID string
  167. Containers int
  168. Images int
  169. Driver string
  170. DriverStatus [][2]string
  171. Plugins PluginsInfo
  172. MemoryLimit bool
  173. SwapLimit bool
  174. CPUCfsPeriod bool `json:"CpuCfsPeriod"`
  175. CPUCfsQuota bool `json:"CpuCfsQuota"`
  176. CPUShares bool
  177. CPUSet bool
  178. IPv4Forwarding bool
  179. BridgeNfIptables bool
  180. BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
  181. Debug bool
  182. NFd int
  183. OomKillDisable bool
  184. NGoroutines int
  185. SystemTime string
  186. ExecutionDriver string
  187. LoggingDriver string
  188. NEventsListener int
  189. KernelVersion string
  190. OperatingSystem string
  191. OSType string
  192. Architecture string
  193. IndexServerAddress string
  194. RegistryConfig *registry.ServiceConfig
  195. InitSha1 string
  196. InitPath string
  197. NCPU int
  198. MemTotal int64
  199. DockerRootDir string
  200. HTTPProxy string `json:"HttpProxy"`
  201. HTTPSProxy string `json:"HttpsProxy"`
  202. NoProxy string
  203. Name string
  204. Labels []string
  205. ExperimentalBuild bool
  206. ServerVersion string
  207. ClusterStore string
  208. ClusterAdvertise string
  209. }
  210. // PluginsInfo is temp struct holds Plugins name
  211. // registered with docker daemon. It used by Info struct
  212. type PluginsInfo struct {
  213. // List of Volume plugins registered
  214. Volume []string
  215. // List of Network plugins registered
  216. Network []string
  217. }
  218. // ExecStartCheck is a temp struct used by execStart
  219. // Config fields is part of ExecConfig in runconfig package
  220. type ExecStartCheck struct {
  221. // ExecStart will first check if it's detached
  222. Detach bool
  223. // Check if there's a tty
  224. Tty bool
  225. }
  226. // ContainerState stores container's running state
  227. // it's part of ContainerJSONBase and will return by "inspect" command
  228. type ContainerState struct {
  229. Status string
  230. Running bool
  231. Paused bool
  232. Restarting bool
  233. OOMKilled bool
  234. Dead bool
  235. Pid int
  236. ExitCode int
  237. Error string
  238. StartedAt string
  239. FinishedAt string
  240. }
  241. // ContainerJSONBase contains response of Remote API:
  242. // GET "/containers/{name:.*}/json"
  243. type ContainerJSONBase struct {
  244. ID string `json:"Id"`
  245. Created string
  246. Path string
  247. Args []string
  248. State *ContainerState
  249. Image string
  250. ResolvConfPath string
  251. HostnamePath string
  252. HostsPath string
  253. LogPath string
  254. Name string
  255. RestartCount int
  256. Driver string
  257. MountLabel string
  258. ProcessLabel string
  259. AppArmorProfile string
  260. ExecIDs []string
  261. HostConfig *runconfig.HostConfig
  262. GraphDriver GraphDriverData
  263. SizeRw *int64 `json:",omitempty"`
  264. SizeRootFs *int64 `json:",omitempty"`
  265. }
  266. // ContainerJSON is newly used struct along with MountPoint
  267. type ContainerJSON struct {
  268. *ContainerJSONBase
  269. Mounts []MountPoint
  270. Config *runconfig.Config
  271. NetworkSettings *NetworkSettings
  272. }
  273. // NetworkSettings exposes the network settings in the api
  274. type NetworkSettings struct {
  275. NetworkSettingsBase
  276. DefaultNetworkSettings
  277. Networks map[string]*network.EndpointSettings
  278. }
  279. // SummaryNetworkSettings provides a summary of container's networks
  280. // in /containers/json
  281. type SummaryNetworkSettings struct {
  282. Networks map[string]*network.EndpointSettings
  283. }
  284. // NetworkSettingsBase holds basic information about networks
  285. type NetworkSettingsBase struct {
  286. Bridge string
  287. SandboxID string
  288. HairpinMode bool
  289. LinkLocalIPv6Address string
  290. LinkLocalIPv6PrefixLen int
  291. Ports nat.PortMap
  292. SandboxKey string
  293. SecondaryIPAddresses []network.Address
  294. SecondaryIPv6Addresses []network.Address
  295. }
  296. // DefaultNetworkSettings holds network information
  297. // during the 2 release deprecation period.
  298. // It will be removed in Docker 1.11.
  299. type DefaultNetworkSettings struct {
  300. EndpointID string
  301. Gateway string
  302. GlobalIPv6Address string
  303. GlobalIPv6PrefixLen int
  304. IPAddress string
  305. IPPrefixLen int
  306. IPv6Gateway string
  307. MacAddress string
  308. }
  309. // MountPoint represents a mount point configuration inside the container.
  310. type MountPoint struct {
  311. Name string `json:",omitempty"`
  312. Source string
  313. Destination string
  314. Driver string `json:",omitempty"`
  315. Mode string
  316. RW bool
  317. Propagation string
  318. }
  319. // Volume represents the configuration of a volume for the remote API
  320. type Volume struct {
  321. Name string // Name is the name of the volume
  322. Driver string // Driver is the Driver name used to create the volume
  323. Mountpoint string // Mountpoint is the location on disk of the volume
  324. }
  325. // VolumesListResponse contains the response for the remote API:
  326. // GET "/volumes"
  327. type VolumesListResponse struct {
  328. Volumes []*Volume // Volumes is the list of volumes being returned
  329. }
  330. // VolumeCreateRequest contains the response for the remote API:
  331. // POST "/volumes/create"
  332. type VolumeCreateRequest struct {
  333. Name string // Name is the requested name of the volume
  334. Driver string // Driver is the name of the driver that should be used to create the volume
  335. DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
  336. }
  337. // NetworkResource is the body of the "get network" http response message
  338. type NetworkResource struct {
  339. Name string
  340. ID string `json:"Id"`
  341. Scope string
  342. Driver string
  343. IPAM network.IPAM
  344. Containers map[string]EndpointResource
  345. Options map[string]string
  346. }
  347. // EndpointResource contains network resources allocated and used for a container in a network
  348. type EndpointResource struct {
  349. Name string
  350. EndpointID string
  351. MacAddress string
  352. IPv4Address string
  353. IPv6Address string
  354. }
  355. // NetworkCreate is the expected body of the "create network" http request message
  356. type NetworkCreate struct {
  357. Name string
  358. CheckDuplicate bool
  359. Driver string
  360. IPAM network.IPAM
  361. Options map[string]string
  362. }
  363. // NetworkCreateResponse is the response message sent by the server for network create call
  364. type NetworkCreateResponse struct {
  365. ID string `json:"Id"`
  366. Warning string
  367. }
  368. // NetworkConnect represents the data to be used to connect a container to the network
  369. type NetworkConnect struct {
  370. Container string
  371. }
  372. // NetworkDisconnect represents the data to be used to disconnect a container from the network
  373. type NetworkDisconnect struct {
  374. Container string
  375. }