backend.go 4.2 KB

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