backend.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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/container"
  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 []LogAttr
  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. // LogAttr is used to hold the extra attributes available in the log message.
  40. type LogAttr struct {
  41. Key string
  42. Value string
  43. }
  44. // LogSelector is a list of services and tasks that should be returned as part
  45. // of a log stream. It is similar to swarmapi.LogSelector, with the difference
  46. // that the names don't have to be resolved to IDs; this is mostly to avoid
  47. // accidents later where a swarmapi LogSelector might have been incorrectly
  48. // used verbatim (and to avoid the handler having to import swarmapi types)
  49. type LogSelector struct {
  50. Services []string
  51. Tasks []string
  52. }
  53. // ContainerStatsConfig holds information for configuring the runtime
  54. // behavior of a backend.ContainerStats() call.
  55. type ContainerStatsConfig struct {
  56. Stream bool
  57. OutStream io.Writer
  58. Version string
  59. }
  60. // ExecInspect holds information about a running process started
  61. // with docker exec.
  62. type ExecInspect struct {
  63. ID string
  64. Running bool
  65. ExitCode *int
  66. ProcessConfig *ExecProcessConfig
  67. OpenStdin bool
  68. OpenStderr bool
  69. OpenStdout bool
  70. CanRemove bool
  71. ContainerID string
  72. DetachKeys []byte
  73. Pid int
  74. }
  75. // ExecProcessConfig holds information about the exec process
  76. // running on the host.
  77. type ExecProcessConfig struct {
  78. Tty bool `json:"tty"`
  79. Entrypoint string `json:"entrypoint"`
  80. Arguments []string `json:"arguments"`
  81. Privileged *bool `json:"privileged,omitempty"`
  82. User string `json:"user,omitempty"`
  83. }
  84. // CreateImageConfig is the configuration for creating an image from a
  85. // container.
  86. type CreateImageConfig struct {
  87. Repo string
  88. Tag string
  89. Pause bool
  90. Author string
  91. Comment string
  92. Config *container.Config
  93. Changes []string
  94. }
  95. // CommitConfig is the configuration for creating an image as part of a build.
  96. type CommitConfig struct {
  97. Author string
  98. Comment string
  99. Config *container.Config
  100. ContainerConfig *container.Config
  101. ContainerID string
  102. ContainerMountLabel string
  103. ContainerOS string
  104. ParentImageID string
  105. }