backend.go 2.8 KB

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