backend.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Package backend includes types to send information to server backends.
  2. package backend
  3. import (
  4. "io"
  5. "github.com/docker/docker/api/types"
  6. "github.com/docker/docker/pkg/streamformatter"
  7. )
  8. // ContainerAttachConfig holds the streams to use when connecting to a container to view logs.
  9. type ContainerAttachConfig struct {
  10. GetStreams func() (io.ReadCloser, io.Writer, io.Writer, error)
  11. UseStdin bool
  12. UseStdout bool
  13. UseStderr bool
  14. Logs bool
  15. Stream bool
  16. DetachKeys string
  17. // Used to signify that streams are multiplexed and therefore need a StdWriter to encode stdout/sderr messages accordingly.
  18. // TODO @cpuguy83: This shouldn't be needed. It was only added so that http and websocket endpoints can use the same function, and the websocket function was not using a stdwriter prior to this change...
  19. // HOWEVER, the websocket endpoint is using a single stream and SHOULD be encoded with stdout/stderr as is done for HTTP since it is still just a single stream.
  20. // Since such a change is an API change unrelated to the current changeset we'll keep it as is here and change separately.
  21. MuxStreams bool
  22. }
  23. // ContainerLogsConfig holds configs for logging operations. Exists
  24. // for users of the backend to to pass it a logging configuration.
  25. type ContainerLogsConfig struct {
  26. types.ContainerLogsOptions
  27. OutStream io.Writer
  28. }
  29. // ContainerStatsConfig holds information for configuring the runtime
  30. // behavior of a backend.ContainerStats() call.
  31. type ContainerStatsConfig struct {
  32. Stream bool
  33. OutStream io.Writer
  34. Version string
  35. }
  36. // ExecInspect holds information about a running process started
  37. // with docker exec.
  38. type ExecInspect struct {
  39. ID string
  40. Running bool
  41. ExitCode *int
  42. ProcessConfig *ExecProcessConfig
  43. OpenStdin bool
  44. OpenStderr bool
  45. OpenStdout bool
  46. CanRemove bool
  47. ContainerID string
  48. DetachKeys []byte
  49. }
  50. // ExecProcessConfig holds information about the exec process
  51. // running on the host.
  52. type ExecProcessConfig struct {
  53. Tty bool `json:"tty"`
  54. Entrypoint string `json:"entrypoint"`
  55. Arguments []string `json:"arguments"`
  56. Privileged *bool `json:"privileged,omitempty"`
  57. User string `json:"user,omitempty"`
  58. }
  59. // ContainerCommitConfig is a wrapper around
  60. // types.ContainerCommitConfig that also
  61. // transports configuration changes for a container.
  62. type ContainerCommitConfig struct {
  63. types.ContainerCommitConfig
  64. Changes []string
  65. }
  66. // ProgressWriter is an interface
  67. // to transport progress streams.
  68. type ProgressWriter struct {
  69. Output io.Writer
  70. StdoutFormatter *streamformatter.StdoutFormatter
  71. StderrFormatter *streamformatter.StderrFormatter
  72. ProgressReaderFunc func(io.ReadCloser) io.ReadCloser
  73. }