backend.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. Pid int
  50. }
  51. // ExecProcessConfig holds information about the exec process
  52. // running on the host.
  53. type ExecProcessConfig struct {
  54. Tty bool `json:"tty"`
  55. Entrypoint string `json:"entrypoint"`
  56. Arguments []string `json:"arguments"`
  57. Privileged *bool `json:"privileged,omitempty"`
  58. User string `json:"user,omitempty"`
  59. }
  60. // ContainerCommitConfig is a wrapper around
  61. // types.ContainerCommitConfig that also
  62. // transports configuration changes for a container.
  63. type ContainerCommitConfig struct {
  64. types.ContainerCommitConfig
  65. Changes []string
  66. }
  67. // ProgressWriter is an interface
  68. // to transport progress streams.
  69. type ProgressWriter struct {
  70. Output io.Writer
  71. StdoutFormatter *streamformatter.StdoutFormatter
  72. StderrFormatter *streamformatter.StderrFormatter
  73. ProgressReaderFunc func(io.ReadCloser) io.ReadCloser
  74. }