backend.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. DefaultReadOnlyNonRecursive 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. }
  83. // ExecInspect holds information about a running process started
  84. // with docker exec.
  85. type ExecInspect struct {
  86. ID string
  87. Running bool
  88. ExitCode *int
  89. ProcessConfig *ExecProcessConfig
  90. OpenStdin bool
  91. OpenStderr bool
  92. OpenStdout bool
  93. CanRemove bool
  94. ContainerID string
  95. DetachKeys []byte
  96. Pid int
  97. }
  98. // ExecProcessConfig holds information about the exec process
  99. // running on the host.
  100. type ExecProcessConfig struct {
  101. Tty bool `json:"tty"`
  102. Entrypoint string `json:"entrypoint"`
  103. Arguments []string `json:"arguments"`
  104. Privileged *bool `json:"privileged,omitempty"`
  105. User string `json:"user,omitempty"`
  106. }
  107. // CreateImageConfig is the configuration for creating an image from a
  108. // container.
  109. type CreateImageConfig struct {
  110. Tag reference.NamedTagged
  111. Pause bool
  112. Author string
  113. Comment string
  114. Config *container.Config
  115. Changes []string
  116. }
  117. // GetImageOpts holds parameters to retrieve image information
  118. // from the backend.
  119. type GetImageOpts struct {
  120. Platform *ocispec.Platform
  121. Details bool
  122. }
  123. // CommitConfig is the configuration for creating an image as part of a build.
  124. type CommitConfig struct {
  125. Author string
  126. Comment string
  127. Config *container.Config
  128. ContainerConfig *container.Config
  129. ContainerID string
  130. ContainerMountLabel string
  131. ContainerOS string
  132. ParentImageID string
  133. }
  134. // PluginRmConfig holds arguments for plugin remove.
  135. type PluginRmConfig struct {
  136. ForceRemove bool
  137. }
  138. // PluginEnableConfig holds arguments for plugin enable
  139. type PluginEnableConfig struct {
  140. Timeout int
  141. }
  142. // PluginDisableConfig holds arguments for plugin disable.
  143. type PluginDisableConfig struct {
  144. ForceDisable bool
  145. }
  146. // NetworkListConfig stores the options available for listing networks
  147. type NetworkListConfig struct {
  148. // TODO(@cpuguy83): naming is hard, this is pulled from what was being used in the router before moving here
  149. Detailed bool
  150. Verbose bool
  151. }