backend.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/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. // PartialLogMetaData provides meta data for a partial log message. Messages
  24. // exceeding a predefined size are split into chunks with this metadata. The
  25. // expectation is for the logger endpoints to assemble the chunks using this
  26. // metadata.
  27. type PartialLogMetaData struct {
  28. Last bool // true if this message is last of a partial
  29. ID string // identifies group of messages comprising a single record
  30. Ordinal int // ordering of message in partial group
  31. }
  32. // LogMessage is datastructure that represents piece of output produced by some
  33. // container. The Line member is a slice of an array whose contents can be
  34. // changed after a log driver's Log() method returns.
  35. // changes to this struct need to be reflect in the reset method in
  36. // daemon/logger/logger.go
  37. type LogMessage struct {
  38. Line []byte
  39. Source string
  40. Timestamp time.Time
  41. Attrs []LogAttr
  42. PLogMetaData *PartialLogMetaData
  43. // Err is an error associated with a message. Completeness of a message
  44. // with Err is not expected, tho it may be partially complete (fields may
  45. // be missing, gibberish, or nil)
  46. Err error
  47. }
  48. // LogAttr is used to hold the extra attributes available in the log message.
  49. type LogAttr struct {
  50. Key string
  51. Value string
  52. }
  53. // LogSelector is a list of services and tasks that should be returned as part
  54. // of a log stream. It is similar to swarmapi.LogSelector, with the difference
  55. // that the names don't have to be resolved to IDs; this is mostly to avoid
  56. // accidents later where a swarmapi LogSelector might have been incorrectly
  57. // used verbatim (and to avoid the handler having to import swarmapi types)
  58. type LogSelector struct {
  59. Services []string
  60. Tasks []string
  61. }
  62. // ContainerStatsConfig holds information for configuring the runtime
  63. // behavior of a backend.ContainerStats() call.
  64. type ContainerStatsConfig struct {
  65. Stream bool
  66. OutStream io.Writer
  67. Version string
  68. }
  69. // ExecInspect holds information about a running process started
  70. // with docker exec.
  71. type ExecInspect struct {
  72. ID string
  73. Running bool
  74. ExitCode *int
  75. ProcessConfig *ExecProcessConfig
  76. OpenStdin bool
  77. OpenStderr bool
  78. OpenStdout bool
  79. CanRemove bool
  80. ContainerID string
  81. DetachKeys []byte
  82. Pid int
  83. }
  84. // ExecProcessConfig holds information about the exec process
  85. // running on the host.
  86. type ExecProcessConfig struct {
  87. Tty bool `json:"tty"`
  88. Entrypoint string `json:"entrypoint"`
  89. Arguments []string `json:"arguments"`
  90. Privileged *bool `json:"privileged,omitempty"`
  91. User string `json:"user,omitempty"`
  92. }
  93. // CreateImageConfig is the configuration for creating an image from a
  94. // container.
  95. type CreateImageConfig struct {
  96. Repo string
  97. Tag string
  98. Pause bool
  99. Author string
  100. Comment string
  101. Config *container.Config
  102. Changes []string
  103. }
  104. // CommitConfig is the configuration for creating an image as part of a build.
  105. type CommitConfig struct {
  106. Author string
  107. Comment string
  108. Config *container.Config
  109. ContainerConfig *container.Config
  110. ContainerID string
  111. ContainerMountLabel string
  112. ContainerOS string
  113. ParentImageID string
  114. }