client.go 5.5 KB

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