backend.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Package backend includes types to send information to server backends.
  2. package backend // import "github.com/docker/docker/api/types/backend"
  3. import (
  4. "io"
  5. "time"
  6. "github.com/docker/docker/api/types"
  7. "github.com/docker/docker/api/types/container"
  8. )
  9. // ContainerAttachConfig holds the streams to use when connecting to a container to view logs.
  10. type ContainerAttachConfig struct {
  11. GetStreams func() (io.ReadCloser, io.Writer, io.Writer, error)
  12. UseStdin bool
  13. UseStdout bool
  14. UseStderr bool
  15. Logs bool
  16. Stream bool
  17. DetachKeys string
  18. // Used to signify that streams are multiplexed and therefore need a StdWriter to encode stdout/stderr messages accordingly.
  19. // 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...
  20. // 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.
  21. // Since such a change is an API change unrelated to the current changeset we'll keep it as is here and change separately.
  22. MuxStreams bool
  23. }
  24. // LogMessage is datastructure that represents piece of output produced by some
  25. // container. The Line member is a slice of an array whose contents can be
  26. // changed after a log driver's Log() method returns.
  27. // changes to this struct need to be reflect in the reset method in
  28. // daemon/logger/logger.go
  29. type LogMessage struct {
  30. Line []byte
  31. Source string
  32. Timestamp time.Time
  33. Attrs []LogAttr
  34. Partial bool
  35. // Err is an error associated with a message. Completeness of a message
  36. // with Err is not expected, tho it may be partially complete (fields may
  37. // be missing, gibberish, or nil)
  38. Err error
  39. }
  40. // LogAttr is used to hold the extra attributes available in the log message.
  41. type LogAttr struct {
  42. Key string
  43. Value string
  44. }
  45. // LogSelector is a list of services and tasks that should be returned as part
  46. // of a log stream. It is similar to swarmapi.LogSelector, with the difference
  47. // that the names don't have to be resolved to IDs; this is mostly to avoid
  48. // accidents later where a swarmapi LogSelector might have been incorrectly
  49. // used verbatim (and to avoid the handler having to import swarmapi types)
  50. type LogSelector struct {
  51. Services []string
  52. Tasks []string
  53. }
  54. // ContainerStatsConfig holds information for configuring the runtime
  55. // behavior of a backend.ContainerStats() call.
  56. type ContainerStatsConfig struct {
  57. Stream bool
  58. OutStream io.Writer
  59. Version string
  60. }
  61. // ExecInspect holds information about a running process started
  62. // with docker exec.
  63. type ExecInspect struct {
  64. ID string
  65. Running bool
  66. ExitCode *int
  67. ProcessConfig *ExecProcessConfig
  68. OpenStdin bool
  69. OpenStderr bool
  70. OpenStdout bool
  71. CanRemove bool
  72. ContainerID string
  73. DetachKeys []byte
  74. Pid int
  75. }
  76. // ExecProcessConfig holds information about the exec process
  77. // running on the host.
  78. type ExecProcessConfig struct {
  79. Tty bool `json:"tty"`
  80. Entrypoint string `json:"entrypoint"`
  81. Arguments []string `json:"arguments"`
  82. Privileged *bool `json:"privileged,omitempty"`
  83. User string `json:"user,omitempty"`
  84. }
  85. // ContainerCommitConfig is a wrapper around
  86. // types.ContainerCommitConfig that also
  87. // transports configuration changes for a container.
  88. type ContainerCommitConfig struct {
  89. types.ContainerCommitConfig
  90. Changes []string
  91. // TODO: ContainerConfig is only used by the dockerfile Builder, so remove it
  92. // once the Builder has been updated to use a different interface
  93. ContainerConfig *container.Config
  94. }