client.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. // ContainerAttachOptions holds parameters to attach to a container.
  11. type ContainerAttachOptions struct {
  12. ContainerID string
  13. Stream bool
  14. Stdin bool
  15. Stdout bool
  16. Stderr bool
  17. DetachKeys string
  18. }
  19. // ContainerCommitOptions holds parameters to commit changes into a container.
  20. type ContainerCommitOptions struct {
  21. ContainerID string
  22. RepositoryName string
  23. Tag string
  24. Comment string
  25. Author string
  26. Changes []string
  27. Pause bool
  28. Config *container.Config
  29. }
  30. // ContainerExecInspect holds information returned by exec inspect.
  31. type ContainerExecInspect struct {
  32. ExecID string
  33. ContainerID string
  34. Running bool
  35. ExitCode int
  36. }
  37. // ContainerListOptions holds parameters to list containers with.
  38. type ContainerListOptions struct {
  39. Quiet bool
  40. Size bool
  41. All bool
  42. Latest bool
  43. Since string
  44. Before string
  45. Limit int
  46. Filter filters.Args
  47. }
  48. // ContainerLogsOptions holds parameters to filter logs with.
  49. type ContainerLogsOptions struct {
  50. ContainerID string
  51. ShowStdout bool
  52. ShowStderr bool
  53. Since string
  54. Timestamps bool
  55. Follow bool
  56. Tail string
  57. }
  58. // ContainerRemoveOptions holds parameters to remove containers.
  59. type ContainerRemoveOptions struct {
  60. ContainerID string
  61. RemoveVolumes bool
  62. RemoveLinks bool
  63. Force bool
  64. }
  65. // CopyToContainerOptions holds information
  66. // about files to copy into a container
  67. type CopyToContainerOptions struct {
  68. ContainerID string
  69. Path string
  70. Content io.Reader
  71. AllowOverwriteDirWithFile bool
  72. }
  73. // EventsOptions hold parameters to filter events with.
  74. type EventsOptions struct {
  75. Since string
  76. Until string
  77. Filters filters.Args
  78. }
  79. // NetworkListOptions holds parameters to filter the list of networks with.
  80. type NetworkListOptions struct {
  81. Filters filters.Args
  82. }
  83. // HijackedResponse holds connection information for a hijacked request.
  84. type HijackedResponse struct {
  85. Conn net.Conn
  86. Reader *bufio.Reader
  87. }
  88. // Close closes the hijacked connection and reader.
  89. func (h *HijackedResponse) Close() {
  90. h.Conn.Close()
  91. }
  92. // CloseWriter is an interface that implement structs
  93. // that close input streams to prevent from writing.
  94. type CloseWriter interface {
  95. CloseWrite() error
  96. }
  97. // CloseWrite closes a readWriter for writing.
  98. func (h *HijackedResponse) CloseWrite() error {
  99. if conn, ok := h.Conn.(CloseWriter); ok {
  100. return conn.CloseWrite()
  101. }
  102. return nil
  103. }
  104. // ImageBuildOptions holds the information
  105. // necessary to build images.
  106. type ImageBuildOptions struct {
  107. Tags []string
  108. SuppressOutput bool
  109. RemoteContext string
  110. NoCache bool
  111. Remove bool
  112. ForceRemove bool
  113. PullParent bool
  114. Isolation string
  115. CPUSetCPUs string
  116. CPUSetMems string
  117. CPUShares int64
  118. CPUQuota int64
  119. CPUPeriod int64
  120. Memory int64
  121. MemorySwap int64
  122. CgroupParent string
  123. ShmSize string
  124. Dockerfile string
  125. Ulimits []*units.Ulimit
  126. BuildArgs []string
  127. AuthConfigs map[string]AuthConfig
  128. Context io.Reader
  129. }
  130. // ImageBuildResponse holds information
  131. // returned by a server after building
  132. // an image.
  133. type ImageBuildResponse struct {
  134. Body io.ReadCloser
  135. OSType string
  136. }
  137. // ImageCreateOptions holds information to create images.
  138. type ImageCreateOptions struct {
  139. // Parent is the image to create this image from
  140. Parent string
  141. // Tag is the name to tag this image
  142. Tag string
  143. // RegistryAuth is the base64 encoded credentials for this server
  144. RegistryAuth string
  145. }
  146. // ImageImportOptions holds information to import images from the client host.
  147. type ImageImportOptions struct {
  148. // Source is the data to send to the server to create this image from
  149. Source io.Reader
  150. // Source is the name of the source to import this image from
  151. SourceName string
  152. // RepositoryName is the name of the repository to import this image
  153. RepositoryName string
  154. // Message is the message to tag the image with
  155. Message string
  156. // Tag is the name to tag this image
  157. Tag string
  158. // Changes are the raw changes to apply to the image
  159. Changes []string
  160. }
  161. // ImageListOptions holds parameters to filter the list of images with.
  162. type ImageListOptions struct {
  163. MatchName string
  164. All bool
  165. Filters filters.Args
  166. }
  167. // ImageLoadResponse returns information to the client about a load process.
  168. type ImageLoadResponse struct {
  169. Body io.ReadCloser
  170. JSON bool
  171. }
  172. // ImagePullOptions holds information to pull images.
  173. type ImagePullOptions struct {
  174. ImageID string
  175. Tag string
  176. // RegistryAuth is the base64 encoded credentials for this server
  177. RegistryAuth string
  178. }
  179. //ImagePushOptions holds information to push images.
  180. type ImagePushOptions ImagePullOptions
  181. // ImageRemoveOptions holds parameters to remove images.
  182. type ImageRemoveOptions struct {
  183. ImageID string
  184. Force bool
  185. PruneChildren bool
  186. }
  187. // ImageSearchOptions holds parameters to search images with.
  188. type ImageSearchOptions struct {
  189. Term string
  190. RegistryAuth string
  191. }
  192. // ImageTagOptions holds parameters to tag an image
  193. type ImageTagOptions struct {
  194. ImageID string
  195. RepositoryName string
  196. Tag string
  197. Force bool
  198. }
  199. // ResizeOptions holds parameters to resize a tty.
  200. // It can be used to resize container ttys and
  201. // exec process ttys too.
  202. type ResizeOptions struct {
  203. ID string
  204. Height int
  205. Width int
  206. }
  207. // VersionResponse holds version information for the client and the server
  208. type VersionResponse struct {
  209. Client *Version
  210. Server *Version
  211. }
  212. // ServerOK return true when the client could connect to the docker server
  213. // and parse the information received. It returns false otherwise.
  214. func (v VersionResponse) ServerOK() bool {
  215. return v.Server != nil
  216. }