backend.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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/distribution/reference"
  7. "github.com/docker/docker/api/types/container"
  8. "github.com/docker/docker/api/types/network"
  9. ocispec "github.com/opencontainers/image-spec/specs-go/v1"
  10. )
  11. // ContainerCreateConfig is the parameter set to ContainerCreate()
  12. type ContainerCreateConfig struct {
  13. Name string
  14. Config *container.Config
  15. HostConfig *container.HostConfig
  16. NetworkingConfig *network.NetworkingConfig
  17. Platform *ocispec.Platform
  18. AdjustCPUShares bool
  19. }
  20. // ContainerRmConfig holds arguments for the container remove
  21. // operation. This struct is used to tell the backend what operations
  22. // to perform.
  23. type ContainerRmConfig struct {
  24. ForceRemove, RemoveVolume, RemoveLink bool
  25. }
  26. // ContainerAttachConfig holds the streams to use when connecting to a container to view logs.
  27. type ContainerAttachConfig struct {
  28. GetStreams func(multiplexed bool) (io.ReadCloser, io.Writer, io.Writer, error)
  29. UseStdin bool
  30. UseStdout bool
  31. UseStderr bool
  32. Logs bool
  33. Stream bool
  34. DetachKeys string
  35. // Used to signify that streams must be multiplexed by producer as endpoint can't manage multiple streams.
  36. // This is typically set by HTTP endpoint, while websocket can transport raw streams
  37. MuxStreams bool
  38. }
  39. // PartialLogMetaData provides meta data for a partial log message. Messages
  40. // exceeding a predefined size are split into chunks with this metadata. The
  41. // expectation is for the logger endpoints to assemble the chunks using this
  42. // metadata.
  43. type PartialLogMetaData struct {
  44. Last bool // true if this message is last of a partial
  45. ID string // identifies group of messages comprising a single record
  46. Ordinal int // ordering of message in partial group
  47. }
  48. // LogMessage is datastructure that represents piece of output produced by some
  49. // container. The Line member is a slice of an array whose contents can be
  50. // changed after a log driver's Log() method returns.
  51. type LogMessage struct {
  52. Line []byte
  53. Source string
  54. Timestamp time.Time
  55. Attrs []LogAttr
  56. PLogMetaData *PartialLogMetaData
  57. // Err is an error associated with a message. Completeness of a message
  58. // with Err is not expected, tho it may be partially complete (fields may
  59. // be missing, gibberish, or nil)
  60. Err error
  61. }
  62. // LogAttr is used to hold the extra attributes available in the log message.
  63. type LogAttr struct {
  64. Key string
  65. Value string
  66. }
  67. // LogSelector is a list of services and tasks that should be returned as part
  68. // of a log stream. It is similar to swarmapi.LogSelector, with the difference
  69. // that the names don't have to be resolved to IDs; this is mostly to avoid
  70. // accidents later where a swarmapi LogSelector might have been incorrectly
  71. // used verbatim (and to avoid the handler having to import swarmapi types)
  72. type LogSelector struct {
  73. Services []string
  74. Tasks []string
  75. }
  76. // ContainerStatsConfig holds information for configuring the runtime
  77. // behavior of a backend.ContainerStats() call.
  78. type ContainerStatsConfig struct {
  79. Stream bool
  80. OneShot bool
  81. OutStream io.Writer
  82. Version string
  83. }
  84. // ExecInspect holds information about a running process started
  85. // with docker exec.
  86. type ExecInspect struct {
  87. ID string
  88. Running bool
  89. ExitCode *int
  90. ProcessConfig *ExecProcessConfig
  91. OpenStdin bool
  92. OpenStderr bool
  93. OpenStdout bool
  94. CanRemove bool
  95. ContainerID string
  96. DetachKeys []byte
  97. Pid int
  98. }
  99. // ExecProcessConfig holds information about the exec process
  100. // running on the host.
  101. type ExecProcessConfig struct {
  102. Tty bool `json:"tty"`
  103. Entrypoint string `json:"entrypoint"`
  104. Arguments []string `json:"arguments"`
  105. Privileged *bool `json:"privileged,omitempty"`
  106. User string `json:"user,omitempty"`
  107. }
  108. // CreateImageConfig is the configuration for creating an image from a
  109. // container.
  110. type CreateImageConfig struct {
  111. Tag reference.NamedTagged
  112. Pause bool
  113. Author string
  114. Comment string
  115. Config *container.Config
  116. Changes []string
  117. }
  118. // CommitConfig is the configuration for creating an image as part of a build.
  119. type CommitConfig struct {
  120. Author string
  121. Comment string
  122. Config *container.Config
  123. ContainerConfig *container.Config
  124. ContainerID string
  125. ContainerMountLabel string
  126. ContainerOS string
  127. ParentImageID string
  128. }
  129. // PluginRmConfig holds arguments for plugin remove.
  130. type PluginRmConfig struct {
  131. ForceRemove bool
  132. }
  133. // PluginEnableConfig holds arguments for plugin enable
  134. type PluginEnableConfig struct {
  135. Timeout int
  136. }
  137. // PluginDisableConfig holds arguments for plugin disable.
  138. type PluginDisableConfig struct {
  139. ForceDisable bool
  140. }
  141. // NetworkListConfig stores the options available for listing networks
  142. type NetworkListConfig struct {
  143. // TODO(@cpuguy83): naming is hard, this is pulled from what was being used in the router before moving here
  144. Detailed bool
  145. Verbose bool
  146. }