types.go 9.0 KB

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