backend.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Package backend includes types to send information to server backends.
  2. package backend
  3. import (
  4. "io"
  5. "time"
  6. "github.com/docker/docker/api/types"
  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/stderr 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. // LogMessage is datastructure that represents piece of output produced by some
  24. // container. The Line member is a slice of an array whose contents can be
  25. // changed after a log driver's Log() method returns.
  26. // changes to this struct need to be reflect in the reset method in
  27. // daemon/logger/logger.go
  28. type LogMessage struct {
  29. Line []byte
  30. Source string
  31. Timestamp time.Time
  32. Attrs LogAttributes
  33. Partial bool
  34. // Err is an error associated with a message. Completeness of a message
  35. // with Err is not expected, tho it may be partially complete (fields may
  36. // be missing, gibberish, or nil)
  37. Err error
  38. }
  39. // LogAttributes is used to hold the extra attributes available in the log message
  40. // Primarily used for converting the map type to string and sorting.
  41. type LogAttributes map[string]string
  42. // LogSelector is a list of services and tasks that should be returned as part
  43. // of a log stream. It is similar to swarmapi.LogSelector, with the difference
  44. // that the names don't have to be resolved to IDs; this is mostly to avoid
  45. // accidents later where a swarmapi LogSelector might have been incorrectly
  46. // used verbatim (and to avoid the handler having to import swarmapi types)
  47. type LogSelector struct {
  48. Services []string
  49. Tasks []string
  50. }
  51. // ContainerStatsConfig holds information for configuring the runtime
  52. // behavior of a backend.ContainerStats() call.
  53. type ContainerStatsConfig struct {
  54. Stream bool
  55. OutStream io.Writer
  56. Version string
  57. }
  58. // ExecInspect holds information about a running process started
  59. // with docker exec.
  60. type ExecInspect struct {
  61. ID string
  62. Running bool
  63. ExitCode *int
  64. ProcessConfig *ExecProcessConfig
  65. OpenStdin bool
  66. OpenStderr bool
  67. OpenStdout bool
  68. CanRemove bool
  69. ContainerID string
  70. DetachKeys []byte
  71. Pid int
  72. }
  73. // ExecProcessConfig holds information about the exec process
  74. // running on the host.
  75. type ExecProcessConfig struct {
  76. Tty bool `json:"tty"`
  77. Entrypoint string `json:"entrypoint"`
  78. Arguments []string `json:"arguments"`
  79. Privileged *bool `json:"privileged,omitempty"`
  80. User string `json:"user,omitempty"`
  81. }
  82. // ContainerCommitConfig is a wrapper around
  83. // types.ContainerCommitConfig that also
  84. // transports configuration changes for a container.
  85. type ContainerCommitConfig struct {
  86. types.ContainerCommitConfig
  87. Changes []string
  88. }