backend.go 5.1 KB

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