types.go 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. ServerVersion string
  198. ClusterStore string
  199. }
  200. // ExecStartCheck is a temp struct used by execStart
  201. // Config fields is part of ExecConfig in runconfig package
  202. type ExecStartCheck struct {
  203. // ExecStart will first check if it's detached
  204. Detach bool
  205. // Check if there's a tty
  206. Tty bool
  207. }
  208. // ContainerState stores container's running state
  209. // it's part of ContainerJSONBase and will return by "inspect" command
  210. type ContainerState struct {
  211. Status string
  212. Running bool
  213. Paused bool
  214. Restarting bool
  215. OOMKilled bool
  216. Dead bool
  217. Pid int
  218. ExitCode int
  219. Error string
  220. StartedAt string
  221. FinishedAt string
  222. }
  223. // ContainerJSONBase contains response of Remote API:
  224. // GET "/containers/{name:.*}/json"
  225. type ContainerJSONBase struct {
  226. ID string `json:"Id"`
  227. Created string
  228. Path string
  229. Args []string
  230. State *ContainerState
  231. Image string
  232. NetworkSettings *network.Settings
  233. ResolvConfPath string
  234. HostnamePath string
  235. HostsPath string
  236. LogPath string
  237. Name string
  238. RestartCount int
  239. Driver string
  240. ExecDriver string
  241. MountLabel string
  242. ProcessLabel string
  243. AppArmorProfile string
  244. ExecIDs []string
  245. HostConfig *runconfig.HostConfig
  246. GraphDriver GraphDriverData
  247. }
  248. // ContainerJSON is newly used struct along with MountPoint
  249. type ContainerJSON struct {
  250. *ContainerJSONBase
  251. Mounts []MountPoint
  252. Config *runconfig.Config
  253. }
  254. // MountPoint represents a mount point configuration inside the container.
  255. type MountPoint struct {
  256. Name string `json:",omitempty"`
  257. Source string
  258. Destination string
  259. Driver string `json:",omitempty"`
  260. Mode string
  261. RW bool
  262. }
  263. // Volume represents the configuration of a volume for the remote API
  264. type Volume struct {
  265. Name string // Name is the name of the volume
  266. Driver string // Driver is the Driver name used to create the volume
  267. Mountpoint string // Mountpoint is the location on disk of the volume
  268. }
  269. // VolumesListResponse contains the response for the remote API:
  270. // GET "/volumes"
  271. type VolumesListResponse struct {
  272. Volumes []*Volume // Volumes is the list of volumes being returned
  273. }
  274. // VolumeCreateRequest contains the response for the remote API:
  275. // POST "/volumes"
  276. type VolumeCreateRequest struct {
  277. Name string // Name is the requested name of the volume
  278. Driver string // Driver is the name of the driver that should be used to create the volume
  279. DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
  280. }