types.go 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. package types
  2. import (
  3. "os"
  4. "time"
  5. "github.com/docker/docker/daemon/network"
  6. "github.com/docker/docker/pkg/version"
  7. "github.com/docker/docker/runconfig"
  8. )
  9. // ContainerCreateResponse contains the information returned to a client on the
  10. // creation of a new container.
  11. type ContainerCreateResponse struct {
  12. // ID is the ID of the created container.
  13. ID string `json:"Id"`
  14. // Warnings are any warnings encountered during the creation of the container.
  15. Warnings []string `json:"Warnings"`
  16. }
  17. // ContainerExecCreateResponse contains response of Remote API:
  18. // POST "/containers/{name:.*}/exec"
  19. type ContainerExecCreateResponse struct {
  20. // ID is the exec ID.
  21. ID string `json:"Id"`
  22. }
  23. // AuthResponse contains response of Remote API:
  24. // POST "/auth"
  25. type AuthResponse struct {
  26. // Status is the authentication status
  27. Status string `json:"Status"`
  28. }
  29. // ContainerWaitResponse contains response of Remote API:
  30. // POST "/containers/"+containerID+"/wait"
  31. type ContainerWaitResponse struct {
  32. // StatusCode is the status code of the wait job
  33. StatusCode int `json:"StatusCode"`
  34. }
  35. // ContainerCommitResponse contains response of Remote API:
  36. // POST "/commit?container="+containerID
  37. type ContainerCommitResponse struct {
  38. ID string `json:"Id"`
  39. }
  40. // ContainerChange contains response of Remote API:
  41. // GET "/containers/{name:.*}/changes"
  42. type ContainerChange struct {
  43. Kind int
  44. Path string
  45. }
  46. // ImageHistory contains response of Remote API:
  47. // GET "/images/{name:.*}/history"
  48. type ImageHistory struct {
  49. ID string `json:"Id"`
  50. Created int64
  51. CreatedBy string
  52. Tags []string
  53. Size int64
  54. Comment string
  55. }
  56. // ImageDelete contains response of Remote API:
  57. // DELETE "/images/{name:.*}"
  58. type ImageDelete struct {
  59. Untagged string `json:",omitempty"`
  60. Deleted string `json:",omitempty"`
  61. }
  62. // Image contains response of Remote API:
  63. // GET "/images/json"
  64. type Image struct {
  65. ID string `json:"Id"`
  66. ParentID string `json:"ParentId"`
  67. RepoTags []string
  68. RepoDigests []string
  69. Created int64
  70. Size int64
  71. VirtualSize int64
  72. Labels map[string]string
  73. }
  74. // GraphDriverData returns Image's graph driver config info
  75. // when calling inspect command
  76. type GraphDriverData struct {
  77. Name string
  78. Data map[string]string
  79. }
  80. // ImageInspect contains response of Remote API:
  81. // GET "/images/{name:.*}/json"
  82. type ImageInspect struct {
  83. ID string `json:"Id"`
  84. Parent string
  85. Comment string
  86. Created string
  87. Container string
  88. ContainerConfig *runconfig.Config
  89. DockerVersion string
  90. Author string
  91. Config *runconfig.Config
  92. Architecture string
  93. Os string
  94. Size int64
  95. VirtualSize int64
  96. GraphDriver GraphDriverData
  97. }
  98. // Port stores open ports info of container
  99. // e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"}
  100. type Port struct {
  101. IP string `json:",omitempty"`
  102. PrivatePort int
  103. PublicPort int `json:",omitempty"`
  104. Type string
  105. }
  106. // Container contains response of Remote API:
  107. // GET "/containers/json"
  108. type Container struct {
  109. ID string `json:"Id"`
  110. Names []string
  111. Image string
  112. Command string
  113. Created int64
  114. Ports []Port
  115. SizeRw int64 `json:",omitempty"`
  116. SizeRootFs int64 `json:",omitempty"`
  117. Labels map[string]string
  118. Status string
  119. HostConfig struct {
  120. NetworkMode string `json:",omitempty"`
  121. }
  122. }
  123. // CopyConfig contains request body of Remote API:
  124. // POST "/containers/"+containerID+"/copy"
  125. type CopyConfig struct {
  126. Resource string
  127. }
  128. // ContainerPathStat is used to encode the header from
  129. // GET "/containers/{name:.*}/archive"
  130. // "Name" is the file or directory name.
  131. type ContainerPathStat struct {
  132. Name string `json:"name"`
  133. Size int64 `json:"size"`
  134. Mode os.FileMode `json:"mode"`
  135. Mtime time.Time `json:"mtime"`
  136. LinkTarget string `json:"linkTarget"`
  137. }
  138. // ContainerProcessList contains response of Remote API:
  139. // GET "/containers/{name:.*}/top"
  140. type ContainerProcessList struct {
  141. Processes [][]string
  142. Titles []string
  143. }
  144. // Version contains response of Remote API:
  145. // GET "/version"
  146. type Version struct {
  147. Version string
  148. APIVersion version.Version `json:"ApiVersion"`
  149. GitCommit string
  150. GoVersion string
  151. Os string
  152. Arch string
  153. KernelVersion string `json:",omitempty"`
  154. Experimental bool `json:",omitempty"`
  155. BuildTime string `json:",omitempty"`
  156. }
  157. // Info contains response of Remote API:
  158. // GET "/info"
  159. type Info struct {
  160. ID string
  161. Containers int
  162. Images int
  163. Driver string
  164. DriverStatus [][2]string
  165. MemoryLimit bool
  166. SwapLimit bool
  167. CPUCfsPeriod bool `json:"CpuCfsPeriod"`
  168. CPUCfsQuota bool `json:"CpuCfsQuota"`
  169. IPv4Forwarding bool
  170. BridgeNfIptables bool
  171. BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
  172. Debug bool
  173. NFd int
  174. OomKillDisable bool
  175. NGoroutines int
  176. SystemTime string
  177. ExecutionDriver string
  178. LoggingDriver string
  179. NEventsListener int
  180. KernelVersion string
  181. OperatingSystem string
  182. IndexServerAddress string
  183. RegistryConfig interface{}
  184. InitSha1 string
  185. InitPath string
  186. NCPU int
  187. MemTotal int64
  188. DockerRootDir string
  189. HTTPProxy string `json:"HttpProxy"`
  190. HTTPSProxy string `json:"HttpsProxy"`
  191. NoProxy string
  192. Name string
  193. Labels []string
  194. ExperimentalBuild bool
  195. }
  196. // ExecStartCheck is a temp struct used by execStart
  197. // Config fields is part of ExecConfig in runconfig package
  198. type ExecStartCheck struct {
  199. // ExecStart will first check if it's detached
  200. Detach bool
  201. // Check if there's a tty
  202. Tty bool
  203. }
  204. // ContainerState stores container's running state
  205. // it's part of ContainerJSONBase and will return by "inspect" command
  206. type ContainerState struct {
  207. Status string
  208. Running bool
  209. Paused bool
  210. Restarting bool
  211. OOMKilled bool
  212. Dead bool
  213. Pid int
  214. ExitCode int
  215. Error string
  216. StartedAt string
  217. FinishedAt string
  218. }
  219. // ContainerJSONBase contains response of Remote API:
  220. // GET "/containers/{name:.*}/json"
  221. type ContainerJSONBase struct {
  222. ID string `json:"Id"`
  223. Created string
  224. Path string
  225. Args []string
  226. State *ContainerState
  227. Image string
  228. NetworkSettings *network.Settings
  229. ResolvConfPath string
  230. HostnamePath string
  231. HostsPath string
  232. LogPath string
  233. Name string
  234. RestartCount int
  235. Driver string
  236. ExecDriver string
  237. MountLabel string
  238. ProcessLabel string
  239. AppArmorProfile string
  240. ExecIDs []string
  241. HostConfig *runconfig.HostConfig
  242. GraphDriver GraphDriverData
  243. }
  244. // ContainerJSON is newly used struct along with MountPoint
  245. type ContainerJSON struct {
  246. *ContainerJSONBase
  247. Mounts []MountPoint
  248. Config *runconfig.Config
  249. }
  250. // ContainerJSON120 is a backcompatibility struct along with ContainerConfig120.
  251. type ContainerJSON120 struct {
  252. *ContainerJSONBase
  253. Mounts []MountPoint
  254. Config *ContainerConfig120
  255. }
  256. // ContainerJSONPre120 is a backcompatibility struct along with ContainerConfigPre120.
  257. // Note this is not used by the Windows daemon.
  258. type ContainerJSONPre120 struct {
  259. *ContainerJSONBase
  260. Volumes map[string]string
  261. VolumesRW map[string]bool
  262. Config *ContainerConfigPre120
  263. }
  264. // ContainerConfigPre120 is a backcompatibility struct used in ContainerJSONPre120
  265. type ContainerConfigPre120 struct {
  266. *runconfig.Config
  267. // backward compatibility, they now live in HostConfig
  268. VolumeDriver string
  269. Memory int64
  270. MemorySwap int64
  271. CPUShares int64 `json:"CpuShares"`
  272. CPUSet string `json:"CpuSet"`
  273. }
  274. // ContainerConfig120 is a backcompatibility struct used in ContainerJSON120
  275. type ContainerConfig120 struct {
  276. *runconfig.Config
  277. // backward compatibility, it lives now in HostConfig
  278. VolumeDriver string
  279. }
  280. // MountPoint represents a mount point configuration inside the container.
  281. type MountPoint struct {
  282. Name string `json:",omitempty"`
  283. Source string
  284. Destination string
  285. Driver string `json:",omitempty"`
  286. Mode string
  287. RW bool
  288. }
  289. // Volume represents the configuration of a volume for the remote API
  290. type Volume struct {
  291. Name string // Name is the name of the volume
  292. Driver string // Driver is the Driver name used to create the volume
  293. Mountpoint string // Mountpoint is the location on disk of the volume
  294. }
  295. // VolumesListResponse contains the response for the remote API:
  296. // GET "/volumes"
  297. type VolumesListResponse struct {
  298. Volumes []*Volume // Volumes is the list of volumes being returned
  299. }
  300. // VolumeCreateRequest contains the response for the remote API:
  301. // POST "/volumes"
  302. type VolumeCreateRequest struct {
  303. Name string // Name is the requested name of the volume
  304. Driver string // Driver is the name of the driver that should be used to create the volume
  305. DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
  306. }