types.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. package types
  2. import (
  3. "os"
  4. "time"
  5. "github.com/docker/docker/daemon/network"
  6. "github.com/docker/docker/pkg/nat"
  7. "github.com/docker/docker/pkg/version"
  8. "github.com/docker/docker/registry"
  9. "github.com/docker/docker/runconfig"
  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. }
  128. // CopyConfig contains request body of Remote API:
  129. // POST "/containers/"+containerID+"/copy"
  130. type CopyConfig struct {
  131. Resource string
  132. }
  133. // ContainerPathStat is used to encode the header from
  134. // GET "/containers/{name:.*}/archive"
  135. // "Name" is the file or directory name.
  136. type ContainerPathStat struct {
  137. Name string `json:"name"`
  138. Size int64 `json:"size"`
  139. Mode os.FileMode `json:"mode"`
  140. Mtime time.Time `json:"mtime"`
  141. LinkTarget string `json:"linkTarget"`
  142. }
  143. // ContainerProcessList contains response of Remote API:
  144. // GET "/containers/{name:.*}/top"
  145. type ContainerProcessList struct {
  146. Processes [][]string
  147. Titles []string
  148. }
  149. // Version contains response of Remote API:
  150. // GET "/version"
  151. type Version struct {
  152. Version string
  153. APIVersion version.Version `json:"ApiVersion"`
  154. GitCommit string
  155. GoVersion string
  156. Os string
  157. Arch string
  158. KernelVersion string `json:",omitempty"`
  159. Experimental bool `json:",omitempty"`
  160. BuildTime string `json:",omitempty"`
  161. }
  162. // Info contains response of Remote API:
  163. // GET "/info"
  164. type Info struct {
  165. ID string
  166. Containers int
  167. Images int
  168. Driver string
  169. DriverStatus [][2]string
  170. MemoryLimit bool
  171. SwapLimit bool
  172. CPUCfsPeriod bool `json:"CpuCfsPeriod"`
  173. CPUCfsQuota bool `json:"CpuCfsQuota"`
  174. IPv4Forwarding bool
  175. BridgeNfIptables bool
  176. BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
  177. Debug bool
  178. NFd int
  179. OomKillDisable bool
  180. NGoroutines int
  181. SystemTime string
  182. ExecutionDriver string
  183. LoggingDriver string
  184. NEventsListener int
  185. KernelVersion string
  186. OperatingSystem string
  187. IndexServerAddress string
  188. RegistryConfig *registry.ServiceConfig
  189. InitSha1 string
  190. InitPath string
  191. NCPU int
  192. MemTotal int64
  193. DockerRootDir string
  194. HTTPProxy string `json:"HttpProxy"`
  195. HTTPSProxy string `json:"HttpsProxy"`
  196. NoProxy string
  197. Name string
  198. Labels []string
  199. ExperimentalBuild bool
  200. ServerVersion string
  201. ClusterStore string
  202. ClusterAdvertise string
  203. }
  204. // ExecStartCheck is a temp struct used by execStart
  205. // Config fields is part of ExecConfig in runconfig package
  206. type ExecStartCheck struct {
  207. // ExecStart will first check if it's detached
  208. Detach bool
  209. // Check if there's a tty
  210. Tty bool
  211. }
  212. // ContainerState stores container's running state
  213. // it's part of ContainerJSONBase and will return by "inspect" command
  214. type ContainerState struct {
  215. Status string
  216. Running bool
  217. Paused bool
  218. Restarting bool
  219. OOMKilled bool
  220. Dead bool
  221. Pid int
  222. ExitCode int
  223. Error string
  224. StartedAt string
  225. FinishedAt string
  226. }
  227. // ContainerJSONBase contains response of Remote API:
  228. // GET "/containers/{name:.*}/json"
  229. type ContainerJSONBase struct {
  230. ID string `json:"Id"`
  231. Created string
  232. Path string
  233. Args []string
  234. State *ContainerState
  235. Image string
  236. ResolvConfPath string
  237. HostnamePath string
  238. HostsPath string
  239. LogPath string
  240. Name string
  241. RestartCount int
  242. Driver string
  243. ExecDriver string
  244. MountLabel string
  245. ProcessLabel string
  246. AppArmorProfile string
  247. ExecIDs []string
  248. HostConfig *runconfig.HostConfig
  249. GraphDriver GraphDriverData
  250. SizeRw *int64 `json:",omitempty"`
  251. SizeRootFs *int64 `json:",omitempty"`
  252. }
  253. // ContainerJSON is newly used struct along with MountPoint
  254. type ContainerJSON struct {
  255. *ContainerJSONBase
  256. Mounts []MountPoint
  257. Config *runconfig.Config
  258. NetworkSettings *NetworkSettings
  259. }
  260. // NetworkSettings exposes the network settings in the api
  261. type NetworkSettings struct {
  262. NetworkSettingsBase
  263. DefaultNetworkSettings
  264. Networks map[string]*network.EndpointSettings
  265. }
  266. // NetworkSettingsBase holds basic information about networks
  267. type NetworkSettingsBase struct {
  268. Bridge string
  269. SandboxID string
  270. HairpinMode bool
  271. LinkLocalIPv6Address string
  272. LinkLocalIPv6PrefixLen int
  273. Ports nat.PortMap
  274. SandboxKey string
  275. SecondaryIPAddresses []network.Address
  276. SecondaryIPv6Addresses []network.Address
  277. }
  278. // DefaultNetworkSettings holds network information
  279. // during the 2 release deprecation period.
  280. // It will be removed in Docker 1.11.
  281. type DefaultNetworkSettings struct {
  282. EndpointID string
  283. Gateway string
  284. GlobalIPv6Address string
  285. GlobalIPv6PrefixLen int
  286. IPAddress string
  287. IPPrefixLen int
  288. IPv6Gateway string
  289. MacAddress string
  290. }
  291. // MountPoint represents a mount point configuration inside the container.
  292. type MountPoint struct {
  293. Name string `json:",omitempty"`
  294. Source string
  295. Destination string
  296. Driver string `json:",omitempty"`
  297. Mode string
  298. RW bool
  299. }
  300. // Volume represents the configuration of a volume for the remote API
  301. type Volume struct {
  302. Name string // Name is the name of the volume
  303. Driver string // Driver is the Driver name used to create the volume
  304. Mountpoint string // Mountpoint is the location on disk of the volume
  305. }
  306. // VolumesListResponse contains the response for the remote API:
  307. // GET "/volumes"
  308. type VolumesListResponse struct {
  309. Volumes []*Volume // Volumes is the list of volumes being returned
  310. }
  311. // VolumeCreateRequest contains the response for the remote API:
  312. // POST "/volumes/create"
  313. type VolumeCreateRequest struct {
  314. Name string // Name is the requested name of the volume
  315. Driver string // Driver is the name of the driver that should be used to create the volume
  316. DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
  317. }
  318. // NetworkResource is the body of the "get network" http response message
  319. type NetworkResource struct {
  320. Name string
  321. ID string `json:"Id"`
  322. Scope string
  323. Driver string
  324. IPAM network.IPAM
  325. Containers map[string]EndpointResource
  326. Options map[string]string
  327. }
  328. //EndpointResource contains network resources allocated and usd for a container in a network
  329. type EndpointResource struct {
  330. EndpointID string
  331. MacAddress string
  332. IPv4Address string
  333. IPv6Address string
  334. }
  335. // NetworkCreate is the expected body of the "create network" http request message
  336. type NetworkCreate struct {
  337. Name string
  338. CheckDuplicate bool
  339. Driver string
  340. IPAM network.IPAM
  341. Options map[string]string
  342. }
  343. // NetworkCreateResponse is the response message sent by the server for network create call
  344. type NetworkCreateResponse struct {
  345. ID string `json:"Id"`
  346. Warning string
  347. }
  348. // NetworkConnect represents the data to be used to connect a container to the network
  349. type NetworkConnect struct {
  350. Container string
  351. }
  352. // NetworkDisconnect represents the data to be used to disconnect a container from the network
  353. type NetworkDisconnect struct {
  354. Container string
  355. }