types.go 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. Running bool
  208. Paused bool
  209. Restarting bool
  210. OOMKilled bool
  211. Dead bool
  212. Pid int
  213. ExitCode int
  214. Error string
  215. StartedAt string
  216. FinishedAt string
  217. }
  218. // ContainerJSONBase contains response of Remote API:
  219. // GET "/containers/{name:.*}/json"
  220. type ContainerJSONBase struct {
  221. ID string `json:"Id"`
  222. Created string
  223. Path string
  224. Args []string
  225. State *ContainerState
  226. Image string
  227. NetworkSettings *network.Settings
  228. ResolvConfPath string
  229. HostnamePath string
  230. HostsPath string
  231. LogPath string
  232. Name string
  233. RestartCount int
  234. Driver string
  235. ExecDriver string
  236. MountLabel string
  237. ProcessLabel string
  238. AppArmorProfile string
  239. ExecIDs []string
  240. HostConfig *runconfig.HostConfig
  241. GraphDriver GraphDriverData
  242. }
  243. // ContainerJSON is newly used struct along with MountPoint
  244. type ContainerJSON struct {
  245. *ContainerJSONBase
  246. Mounts []MountPoint
  247. Config *runconfig.Config
  248. }
  249. // ContainerJSONPre120 is a backcompatibility struct along with ContainerConfig.
  250. // Note this is not used by the Windows daemon.
  251. type ContainerJSONPre120 struct {
  252. *ContainerJSONBase
  253. Volumes map[string]string
  254. VolumesRW map[string]bool
  255. Config *ContainerConfig
  256. }
  257. // ContainerConfig is a backcompatibility struct used in ContainerJSONPre120
  258. type ContainerConfig struct {
  259. *runconfig.Config
  260. // backward compatibility, they now live in HostConfig
  261. Memory int64
  262. MemorySwap int64
  263. CPUShares int64 `json:"CpuShares"`
  264. CPUSet string `json:"CpuSet"`
  265. }
  266. // MountPoint represents a mount point configuration inside the container.
  267. type MountPoint struct {
  268. Name string `json:",omitempty"`
  269. Source string
  270. Destination string
  271. Driver string `json:",omitempty"`
  272. Mode string
  273. RW bool
  274. }
  275. // Volume represents the configuration of a volume for the remote API
  276. type Volume struct {
  277. Name string // Name is the name of the volume
  278. Driver string // Driver is the Driver name used to create the volume
  279. Mountpoint string // Mountpoint is the location on disk of the volume
  280. }
  281. // VolumesListResponse contains the response for the remote API:
  282. // GET "/volumes"
  283. type VolumesListResponse struct {
  284. Volumes []*Volume // Volumes is the list of volumes being returned
  285. }
  286. // VolumeCreateRequest contains the response for the remote API:
  287. // POST "/volumes"
  288. type VolumeCreateRequest struct {
  289. Name string // Name is the requested name of the volume
  290. Driver string // Driver is the name of the driver that should be used to create the volume
  291. DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
  292. }