client.go 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. package types
  2. import (
  3. "bufio"
  4. "io"
  5. "net"
  6. "github.com/docker/docker/api/types/container"
  7. "github.com/docker/docker/api/types/filters"
  8. "github.com/docker/go-units"
  9. )
  10. // CheckpointCreateOptions holds parameters to create a checkpoint from a container
  11. type CheckpointCreateOptions struct {
  12. CheckpointID string
  13. Exit bool
  14. }
  15. // ContainerAttachOptions holds parameters to attach to a container.
  16. type ContainerAttachOptions struct {
  17. Stream bool
  18. Stdin bool
  19. Stdout bool
  20. Stderr bool
  21. DetachKeys string
  22. }
  23. // ContainerCommitOptions holds parameters to commit changes into a container.
  24. type ContainerCommitOptions struct {
  25. Reference string
  26. Comment string
  27. Author string
  28. Changes []string
  29. Pause bool
  30. Config *container.Config
  31. }
  32. // ContainerExecInspect holds information returned by exec inspect.
  33. type ContainerExecInspect struct {
  34. ExecID string
  35. ContainerID string
  36. Running bool
  37. ExitCode int
  38. }
  39. // ContainerListOptions holds parameters to list containers with.
  40. type ContainerListOptions struct {
  41. Quiet bool
  42. Size bool
  43. All bool
  44. Latest bool
  45. Since string
  46. Before string
  47. Limit int
  48. Filter filters.Args
  49. }
  50. // ContainerLogsOptions holds parameters to filter logs with.
  51. type ContainerLogsOptions struct {
  52. ShowStdout bool
  53. ShowStderr bool
  54. Since string
  55. Timestamps bool
  56. Follow bool
  57. Tail string
  58. Details bool
  59. }
  60. // ContainerRemoveOptions holds parameters to remove containers.
  61. type ContainerRemoveOptions struct {
  62. RemoveVolumes bool
  63. RemoveLinks bool
  64. Force bool
  65. }
  66. // ContainerStartOptions holds parameters to start containers.
  67. type ContainerStartOptions struct {
  68. CheckpointID string
  69. }
  70. // CopyToContainerOptions holds information
  71. // about files to copy into a container
  72. type CopyToContainerOptions struct {
  73. AllowOverwriteDirWithFile bool
  74. }
  75. // EventsOptions holds parameters to filter events with.
  76. type EventsOptions struct {
  77. Since string
  78. Until string
  79. Filters filters.Args
  80. }
  81. // NetworkListOptions holds parameters to filter the list of networks with.
  82. type NetworkListOptions struct {
  83. Filters filters.Args
  84. }
  85. // HijackedResponse holds connection information for a hijacked request.
  86. type HijackedResponse struct {
  87. Conn net.Conn
  88. Reader *bufio.Reader
  89. }
  90. // Close closes the hijacked connection and reader.
  91. func (h *HijackedResponse) Close() {
  92. h.Conn.Close()
  93. }
  94. // CloseWriter is an interface that implements structs
  95. // that close input streams to prevent from writing.
  96. type CloseWriter interface {
  97. CloseWrite() error
  98. }
  99. // CloseWrite closes a readWriter for writing.
  100. func (h *HijackedResponse) CloseWrite() error {
  101. if conn, ok := h.Conn.(CloseWriter); ok {
  102. return conn.CloseWrite()
  103. }
  104. return nil
  105. }
  106. // ImageBuildOptions holds the information
  107. // necessary to build images.
  108. type ImageBuildOptions struct {
  109. Tags []string
  110. SuppressOutput bool
  111. RemoteContext string
  112. NoCache bool
  113. Remove bool
  114. ForceRemove bool
  115. PullParent bool
  116. Isolation container.Isolation
  117. CPUSetCPUs string
  118. CPUSetMems string
  119. CPUShares int64
  120. CPUQuota int64
  121. CPUPeriod int64
  122. Memory int64
  123. MemorySwap int64
  124. CgroupParent string
  125. ShmSize int64
  126. Dockerfile string
  127. Ulimits []*units.Ulimit
  128. BuildArgs map[string]string
  129. AuthConfigs map[string]AuthConfig
  130. Context io.Reader
  131. Labels map[string]string
  132. // squash the resulting image's layers to the parent
  133. // preserves the original image and creates a new one from the parent with all
  134. // the changes applied to a single layer
  135. Squash bool
  136. // CacheFrom specifies images that are used for matching cache. Images
  137. // specified here do not need to have a valid parent chain to match cache.
  138. CacheFrom []string
  139. SecurityOpt []string
  140. }
  141. // ImageBuildResponse holds information
  142. // returned by a server after building
  143. // an image.
  144. type ImageBuildResponse struct {
  145. Body io.ReadCloser
  146. OSType string
  147. }
  148. // ImageCreateOptions holds information to create images.
  149. type ImageCreateOptions struct {
  150. RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
  151. }
  152. // ImageImportSource holds source information for ImageImport
  153. type ImageImportSource struct {
  154. Source io.Reader // Source is the data to send to the server to create this image from (mutually exclusive with SourceName)
  155. SourceName string // SourceName is the name of the image to pull (mutually exclusive with Source)
  156. }
  157. // ImageImportOptions holds information to import images from the client host.
  158. type ImageImportOptions struct {
  159. Tag string // Tag is the name to tag this image with. This attribute is deprecated.
  160. Message string // Message is the message to tag the image with
  161. Changes []string // Changes are the raw changes to apply to this image
  162. }
  163. // ImageListOptions holds parameters to filter the list of images with.
  164. type ImageListOptions struct {
  165. MatchName string
  166. All bool
  167. Filters filters.Args
  168. }
  169. // ImageLoadResponse returns information to the client about a load process.
  170. type ImageLoadResponse struct {
  171. // Body must be closed to avoid a resource leak
  172. Body io.ReadCloser
  173. JSON bool
  174. }
  175. // ImagePullOptions holds information to pull images.
  176. type ImagePullOptions struct {
  177. All bool
  178. RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
  179. PrivilegeFunc RequestPrivilegeFunc
  180. }
  181. // RequestPrivilegeFunc is a function interface that
  182. // clients can supply to retry operations after
  183. // getting an authorization error.
  184. // This function returns the registry authentication
  185. // header value in base 64 format, or an error
  186. // if the privilege request fails.
  187. type RequestPrivilegeFunc func() (string, error)
  188. //ImagePushOptions holds information to push images.
  189. type ImagePushOptions ImagePullOptions
  190. // ImageRemoveOptions holds parameters to remove images.
  191. type ImageRemoveOptions struct {
  192. Force bool
  193. PruneChildren bool
  194. }
  195. // ImageSearchOptions holds parameters to search images with.
  196. type ImageSearchOptions struct {
  197. RegistryAuth string
  198. PrivilegeFunc RequestPrivilegeFunc
  199. Filters filters.Args
  200. Limit int
  201. }
  202. // ResizeOptions holds parameters to resize a tty.
  203. // It can be used to resize container ttys and
  204. // exec process ttys too.
  205. type ResizeOptions struct {
  206. Height uint
  207. Width uint
  208. }
  209. // VersionResponse holds version information for the client and the server
  210. type VersionResponse struct {
  211. Client *Version
  212. Server *Version
  213. }
  214. // ServerOK returns true when the client could connect to the docker server
  215. // and parse the information received. It returns false otherwise.
  216. func (v VersionResponse) ServerOK() bool {
  217. return v.Server != nil
  218. }
  219. // NodeListOptions holds parameters to list nodes with.
  220. type NodeListOptions struct {
  221. Filter filters.Args
  222. }
  223. // NodeRemoveOptions holds parameters to remove nodes with.
  224. type NodeRemoveOptions struct {
  225. Force bool
  226. }
  227. // ServiceCreateOptions contains the options to use when creating a service.
  228. type ServiceCreateOptions struct {
  229. // EncodedRegistryAuth is the encoded registry authorization credentials to
  230. // use when updating the service.
  231. //
  232. // This field follows the format of the X-Registry-Auth header.
  233. EncodedRegistryAuth string
  234. }
  235. // ServiceCreateResponse contains the information returned to a client
  236. // on the creation of a new service.
  237. type ServiceCreateResponse struct {
  238. // ID is the ID of the created service.
  239. ID string
  240. }
  241. // ServiceUpdateOptions contains the options to be used for updating services.
  242. type ServiceUpdateOptions struct {
  243. // EncodedRegistryAuth is the encoded registry authorization credentials to
  244. // use when updating the service.
  245. //
  246. // This field follows the format of the X-Registry-Auth header.
  247. EncodedRegistryAuth string
  248. // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
  249. // into this field. While it does open API users up to racy writes, most
  250. // users may not need that level of consistency in practice.
  251. }
  252. // ServiceListOptions holds parameters to list services with.
  253. type ServiceListOptions struct {
  254. Filter filters.Args
  255. }
  256. // TaskListOptions holds parameters to list tasks with.
  257. type TaskListOptions struct {
  258. Filter filters.Args
  259. }
  260. // PluginRemoveOptions holds parameters to remove plugins.
  261. type PluginRemoveOptions struct {
  262. Force bool
  263. }