dryrunclient.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*
  2. Copyright 2020 Docker Compose CLI authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package api
  14. import (
  15. "bytes"
  16. "context"
  17. "crypto/rand"
  18. "encoding/json"
  19. "errors"
  20. "fmt"
  21. "io"
  22. "net"
  23. "net/http"
  24. "runtime"
  25. "strings"
  26. "sync"
  27. "github.com/docker/buildx/builder"
  28. "github.com/docker/buildx/util/imagetools"
  29. "github.com/docker/cli/cli/command"
  30. moby "github.com/docker/docker/api/types"
  31. "github.com/docker/docker/api/types/build"
  32. "github.com/docker/docker/api/types/checkpoint"
  33. containerType "github.com/docker/docker/api/types/container"
  34. "github.com/docker/docker/api/types/events"
  35. "github.com/docker/docker/api/types/filters"
  36. "github.com/docker/docker/api/types/image"
  37. "github.com/docker/docker/api/types/network"
  38. "github.com/docker/docker/api/types/registry"
  39. "github.com/docker/docker/api/types/swarm"
  40. "github.com/docker/docker/api/types/system"
  41. "github.com/docker/docker/api/types/volume"
  42. "github.com/docker/docker/client"
  43. "github.com/docker/docker/pkg/jsonmessage"
  44. specs "github.com/opencontainers/image-spec/specs-go/v1"
  45. )
  46. const (
  47. DRYRUN_PREFIX = " DRY-RUN MODE - "
  48. )
  49. var _ client.APIClient = &DryRunClient{}
  50. type DryRunKey struct{}
  51. // DryRunClient implements APIClient by delegating to implementation functions. This allows lazy init and per-method overrides
  52. type DryRunClient struct {
  53. apiClient client.APIClient
  54. containers []containerType.Summary
  55. execs sync.Map
  56. resolver *imagetools.Resolver
  57. }
  58. type execDetails struct {
  59. container string
  60. command []string
  61. }
  62. // NewDryRunClient produces a DryRunClient
  63. func NewDryRunClient(apiClient client.APIClient, cli command.Cli) (*DryRunClient, error) {
  64. b, err := builder.New(cli, builder.WithSkippedValidation())
  65. if err != nil {
  66. return nil, err
  67. }
  68. configFile, err := b.ImageOpt()
  69. if err != nil {
  70. return nil, err
  71. }
  72. return &DryRunClient{
  73. apiClient: apiClient,
  74. containers: []containerType.Summary{},
  75. execs: sync.Map{},
  76. resolver: imagetools.New(configFile),
  77. }, nil
  78. }
  79. func getCallingFunction() string {
  80. pc, _, _, _ := runtime.Caller(2)
  81. fullName := runtime.FuncForPC(pc).Name()
  82. return fullName[strings.LastIndex(fullName, ".")+1:]
  83. }
  84. // All methods and functions which need to be overridden for dry run.
  85. func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options containerType.AttachOptions) (moby.HijackedResponse, error) {
  86. return moby.HijackedResponse{}, errors.New("interactive run is not supported in dry-run mode")
  87. }
  88. func (d *DryRunClient) ContainerCreate(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig,
  89. networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string,
  90. ) (containerType.CreateResponse, error) {
  91. d.containers = append(d.containers, containerType.Summary{
  92. ID: containerName,
  93. Names: []string{containerName},
  94. Labels: config.Labels,
  95. HostConfig: struct {
  96. NetworkMode string `json:",omitempty"`
  97. Annotations map[string]string `json:",omitempty"`
  98. }{},
  99. })
  100. return containerType.CreateResponse{ID: containerName}, nil
  101. }
  102. func (d *DryRunClient) ContainerInspect(ctx context.Context, container string) (containerType.InspectResponse, error) {
  103. containerJSON, err := d.apiClient.ContainerInspect(ctx, container)
  104. if err != nil {
  105. id := "dryRunId"
  106. for _, c := range d.containers {
  107. if c.ID == container {
  108. id = container
  109. }
  110. }
  111. return containerType.InspectResponse{
  112. ContainerJSONBase: &containerType.ContainerJSONBase{
  113. ID: id,
  114. Name: container,
  115. State: &containerType.State{
  116. Status: containerType.StateRunning, // needed for --wait option
  117. Health: &containerType.Health{
  118. Status: containerType.Healthy, // needed for healthcheck control
  119. },
  120. },
  121. },
  122. Mounts: nil,
  123. Config: &containerType.Config{},
  124. NetworkSettings: &containerType.NetworkSettings{},
  125. }, nil
  126. }
  127. return containerJSON, err
  128. }
  129. func (d *DryRunClient) ContainerKill(ctx context.Context, container, signal string) error {
  130. return nil
  131. }
  132. func (d *DryRunClient) ContainerList(ctx context.Context, options containerType.ListOptions) ([]containerType.Summary, error) {
  133. caller := getCallingFunction()
  134. switch caller {
  135. case "start":
  136. return d.containers, nil
  137. case "getContainers":
  138. if len(d.containers) == 0 {
  139. var err error
  140. d.containers, err = d.apiClient.ContainerList(ctx, options)
  141. return d.containers, err
  142. }
  143. }
  144. return d.apiClient.ContainerList(ctx, options)
  145. }
  146. func (d *DryRunClient) ContainerPause(ctx context.Context, container string) error {
  147. return nil
  148. }
  149. func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options containerType.RemoveOptions) error {
  150. return nil
  151. }
  152. func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error {
  153. return nil
  154. }
  155. func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, options containerType.StopOptions) error {
  156. return nil
  157. }
  158. func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options containerType.StartOptions) error {
  159. return nil
  160. }
  161. func (d *DryRunClient) ContainerStop(ctx context.Context, container string, options containerType.StopOptions) error {
  162. return nil
  163. }
  164. func (d *DryRunClient) ContainerUnpause(ctx context.Context, container string) error {
  165. return nil
  166. }
  167. func (d *DryRunClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, containerType.PathStat, error) {
  168. rc := io.NopCloser(strings.NewReader(""))
  169. if _, err := d.ContainerStatPath(ctx, container, srcPath); err != nil {
  170. return rc, containerType.PathStat{}, fmt.Errorf(" %s Could not find the file %s in container %s", DRYRUN_PREFIX, srcPath, container)
  171. }
  172. return rc, containerType.PathStat{}, nil
  173. }
  174. func (d *DryRunClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options containerType.CopyToContainerOptions) error {
  175. if _, err := d.ContainerStatPath(ctx, container, path); err != nil {
  176. return fmt.Errorf(" %s Could not find the file %s in container %s", DRYRUN_PREFIX, path, container)
  177. }
  178. return nil
  179. }
  180. func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) {
  181. jsonMessage, err := json.Marshal(&jsonmessage.JSONMessage{
  182. Status: fmt.Sprintf("%[1]sSuccessfully built: dryRunID\n%[1]sSuccessfully tagged: %[2]s\n", DRYRUN_PREFIX, options.Tags[0]),
  183. Progress: &jsonmessage.JSONProgress{},
  184. ID: "",
  185. })
  186. if err != nil {
  187. return build.ImageBuildResponse{}, err
  188. }
  189. rc := io.NopCloser(bytes.NewReader(jsonMessage))
  190. return build.ImageBuildResponse{
  191. Body: rc,
  192. OSType: "",
  193. }, nil
  194. }
  195. func (d *DryRunClient) ImageInspect(ctx context.Context, imageName string, options ...client.ImageInspectOption) (image.InspectResponse, error) {
  196. caller := getCallingFunction()
  197. switch caller {
  198. case "pullServiceImage", "buildContainerVolumes":
  199. return image.InspectResponse{ID: "dryRunId"}, nil
  200. default:
  201. return d.apiClient.ImageInspect(ctx, imageName, options...)
  202. }
  203. }
  204. // Deprecated: Use [DryRunClient.ImageInspect] instead; raw response can be obtained by [client.ImageInspectWithRawResponse] option.
  205. func (d *DryRunClient) ImageInspectWithRaw(ctx context.Context, imageName string) (image.InspectResponse, []byte, error) {
  206. var buf bytes.Buffer
  207. resp, err := d.ImageInspect(ctx, imageName, client.ImageInspectWithRawResponse(&buf))
  208. if err != nil {
  209. return image.InspectResponse{}, nil, err
  210. }
  211. return resp, buf.Bytes(), err
  212. }
  213. func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) {
  214. if _, _, err := d.resolver.Resolve(ctx, ref); err != nil {
  215. return nil, err
  216. }
  217. rc := io.NopCloser(strings.NewReader(""))
  218. return rc, nil
  219. }
  220. func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error) {
  221. if _, _, err := d.resolver.Resolve(ctx, ref); err != nil {
  222. return nil, err
  223. }
  224. jsonMessage, err := json.Marshal(&jsonmessage.JSONMessage{
  225. Status: "Pushed",
  226. Progress: &jsonmessage.JSONProgress{
  227. Current: 100,
  228. Total: 100,
  229. Start: 0,
  230. HideCounts: false,
  231. Units: "Mb",
  232. },
  233. ID: ref,
  234. })
  235. if err != nil {
  236. return nil, err
  237. }
  238. rc := io.NopCloser(bytes.NewReader(jsonMessage))
  239. return rc, nil
  240. }
  241. func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
  242. return nil, nil
  243. }
  244. func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, container string, config *network.EndpointSettings) error {
  245. return nil
  246. }
  247. func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
  248. return network.CreateResponse{
  249. ID: name,
  250. Warning: "",
  251. }, nil
  252. }
  253. func (d *DryRunClient) NetworkDisconnect(ctx context.Context, networkName, container string, force bool) error {
  254. return nil
  255. }
  256. func (d *DryRunClient) NetworkRemove(ctx context.Context, networkName string) error {
  257. return nil
  258. }
  259. func (d *DryRunClient) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
  260. return volume.Volume{
  261. ClusterVolume: nil,
  262. Driver: options.Driver,
  263. Labels: options.Labels,
  264. Name: options.Name,
  265. Options: options.DriverOpts,
  266. }, nil
  267. }
  268. func (d *DryRunClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
  269. return nil
  270. }
  271. func (d *DryRunClient) ContainerExecCreate(ctx context.Context, container string, config containerType.ExecOptions) (containerType.ExecCreateResponse, error) {
  272. b := make([]byte, 32)
  273. _, _ = rand.Read(b)
  274. id := fmt.Sprintf("%x", b)
  275. d.execs.Store(id, execDetails{
  276. container: container,
  277. command: config.Cmd,
  278. })
  279. return containerType.ExecCreateResponse{
  280. ID: id,
  281. }, nil
  282. }
  283. func (d *DryRunClient) ContainerExecStart(ctx context.Context, execID string, config containerType.ExecStartOptions) error {
  284. v, ok := d.execs.LoadAndDelete(execID)
  285. if !ok {
  286. return fmt.Errorf("invalid exec ID %q", execID)
  287. }
  288. details := v.(execDetails)
  289. fmt.Printf("%sExecuting command %q in %s (detached mode)\n", DRYRUN_PREFIX, details.command, details.container)
  290. return nil
  291. }
  292. // Functions delegated to original APIClient (not used by Compose or not modifying the Compose stack
  293. func (d *DryRunClient) ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
  294. return d.apiClient.ConfigList(ctx, options)
  295. }
  296. func (d *DryRunClient) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error) {
  297. return d.apiClient.ConfigCreate(ctx, config)
  298. }
  299. func (d *DryRunClient) ConfigRemove(ctx context.Context, id string) error {
  300. return d.apiClient.ConfigRemove(ctx, id)
  301. }
  302. func (d *DryRunClient) ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error) {
  303. return d.apiClient.ConfigInspectWithRaw(ctx, name)
  304. }
  305. func (d *DryRunClient) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error {
  306. return d.apiClient.ConfigUpdate(ctx, id, version, config)
  307. }
  308. func (d *DryRunClient) ContainerCommit(ctx context.Context, container string, options containerType.CommitOptions) (containerType.CommitResponse, error) {
  309. return d.apiClient.ContainerCommit(ctx, container, options)
  310. }
  311. func (d *DryRunClient) ContainerDiff(ctx context.Context, container string) ([]containerType.FilesystemChange, error) {
  312. return d.apiClient.ContainerDiff(ctx, container)
  313. }
  314. func (d *DryRunClient) ContainerExecAttach(ctx context.Context, execID string, config containerType.ExecStartOptions) (moby.HijackedResponse, error) {
  315. return moby.HijackedResponse{}, errors.New("interactive exec is not supported in dry-run mode")
  316. }
  317. func (d *DryRunClient) ContainerExecInspect(ctx context.Context, execID string) (containerType.ExecInspect, error) {
  318. return d.apiClient.ContainerExecInspect(ctx, execID)
  319. }
  320. func (d *DryRunClient) ContainerExecResize(ctx context.Context, execID string, options containerType.ResizeOptions) error {
  321. return d.apiClient.ContainerExecResize(ctx, execID, options)
  322. }
  323. func (d *DryRunClient) ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) {
  324. return d.apiClient.ContainerExport(ctx, container)
  325. }
  326. func (d *DryRunClient) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (containerType.InspectResponse, []byte, error) {
  327. return d.apiClient.ContainerInspectWithRaw(ctx, container, getSize)
  328. }
  329. func (d *DryRunClient) ContainerLogs(ctx context.Context, container string, options containerType.LogsOptions) (io.ReadCloser, error) {
  330. return d.apiClient.ContainerLogs(ctx, container, options)
  331. }
  332. func (d *DryRunClient) ContainerResize(ctx context.Context, container string, options containerType.ResizeOptions) error {
  333. return d.apiClient.ContainerResize(ctx, container, options)
  334. }
  335. func (d *DryRunClient) ContainerStatPath(ctx context.Context, container, path string) (containerType.PathStat, error) {
  336. return d.apiClient.ContainerStatPath(ctx, container, path)
  337. }
  338. func (d *DryRunClient) ContainerStats(ctx context.Context, container string, stream bool) (containerType.StatsResponseReader, error) {
  339. return d.apiClient.ContainerStats(ctx, container, stream)
  340. }
  341. func (d *DryRunClient) ContainerStatsOneShot(ctx context.Context, container string) (containerType.StatsResponseReader, error) {
  342. return d.apiClient.ContainerStatsOneShot(ctx, container)
  343. }
  344. func (d *DryRunClient) ContainerTop(ctx context.Context, container string, arguments []string) (containerType.TopResponse, error) {
  345. return d.apiClient.ContainerTop(ctx, container, arguments)
  346. }
  347. func (d *DryRunClient) ContainerUpdate(ctx context.Context, container string, updateConfig containerType.UpdateConfig) (containerType.UpdateResponse, error) {
  348. return d.apiClient.ContainerUpdate(ctx, container, updateConfig)
  349. }
  350. func (d *DryRunClient) ContainerWait(ctx context.Context, container string, condition containerType.WaitCondition) (<-chan containerType.WaitResponse, <-chan error) {
  351. return d.apiClient.ContainerWait(ctx, container, condition)
  352. }
  353. func (d *DryRunClient) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (containerType.PruneReport, error) {
  354. return d.apiClient.ContainersPrune(ctx, pruneFilters)
  355. }
  356. func (d *DryRunClient) DistributionInspect(ctx context.Context, imageName, encodedRegistryAuth string) (registry.DistributionInspect, error) {
  357. return d.apiClient.DistributionInspect(ctx, imageName, encodedRegistryAuth)
  358. }
  359. func (d *DryRunClient) BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) {
  360. return d.apiClient.BuildCachePrune(ctx, opts)
  361. }
  362. func (d *DryRunClient) BuildCancel(ctx context.Context, id string) error {
  363. return d.apiClient.BuildCancel(ctx, id)
  364. }
  365. func (d *DryRunClient) ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) {
  366. return d.apiClient.ImageCreate(ctx, parentReference, options)
  367. }
  368. func (d *DryRunClient) ImageHistory(ctx context.Context, imageName string, options ...client.ImageHistoryOption) ([]image.HistoryResponseItem, error) {
  369. return d.apiClient.ImageHistory(ctx, imageName, options...)
  370. }
  371. func (d *DryRunClient) ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
  372. return d.apiClient.ImageImport(ctx, source, ref, options)
  373. }
  374. func (d *DryRunClient) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error) {
  375. return d.apiClient.ImageList(ctx, options)
  376. }
  377. func (d *DryRunClient) ImageLoad(ctx context.Context, input io.Reader, options ...client.ImageLoadOption) (image.LoadResponse, error) {
  378. return d.apiClient.ImageLoad(ctx, input, options...)
  379. }
  380. func (d *DryRunClient) ImageSearch(ctx context.Context, term string, options registry.SearchOptions) ([]registry.SearchResult, error) {
  381. return d.apiClient.ImageSearch(ctx, term, options)
  382. }
  383. func (d *DryRunClient) ImageSave(ctx context.Context, images []string, options ...client.ImageSaveOption) (io.ReadCloser, error) {
  384. return d.apiClient.ImageSave(ctx, images, options...)
  385. }
  386. func (d *DryRunClient) ImageTag(ctx context.Context, imageName, ref string) error {
  387. return d.apiClient.ImageTag(ctx, imageName, ref)
  388. }
  389. func (d *DryRunClient) ImagesPrune(ctx context.Context, pruneFilter filters.Args) (image.PruneReport, error) {
  390. return d.apiClient.ImagesPrune(ctx, pruneFilter)
  391. }
  392. func (d *DryRunClient) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) {
  393. return d.apiClient.NodeInspectWithRaw(ctx, nodeID)
  394. }
  395. func (d *DryRunClient) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
  396. return d.apiClient.NodeList(ctx, options)
  397. }
  398. func (d *DryRunClient) NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error {
  399. return d.apiClient.NodeRemove(ctx, nodeID, options)
  400. }
  401. func (d *DryRunClient) NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error {
  402. return d.apiClient.NodeUpdate(ctx, nodeID, version, node)
  403. }
  404. func (d *DryRunClient) NetworkInspect(ctx context.Context, networkName string, options network.InspectOptions) (network.Inspect, error) {
  405. return d.apiClient.NetworkInspect(ctx, networkName, options)
  406. }
  407. func (d *DryRunClient) NetworkInspectWithRaw(ctx context.Context, networkName string, options network.InspectOptions) (network.Inspect, []byte, error) {
  408. return d.apiClient.NetworkInspectWithRaw(ctx, networkName, options)
  409. }
  410. func (d *DryRunClient) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Inspect, error) {
  411. return d.apiClient.NetworkList(ctx, options)
  412. }
  413. func (d *DryRunClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error) {
  414. return d.apiClient.NetworksPrune(ctx, pruneFilter)
  415. }
  416. func (d *DryRunClient) PluginList(ctx context.Context, filter filters.Args) (moby.PluginsListResponse, error) {
  417. return d.apiClient.PluginList(ctx, filter)
  418. }
  419. func (d *DryRunClient) PluginRemove(ctx context.Context, name string, options moby.PluginRemoveOptions) error {
  420. return d.apiClient.PluginRemove(ctx, name, options)
  421. }
  422. func (d *DryRunClient) PluginEnable(ctx context.Context, name string, options moby.PluginEnableOptions) error {
  423. return d.apiClient.PluginEnable(ctx, name, options)
  424. }
  425. func (d *DryRunClient) PluginDisable(ctx context.Context, name string, options moby.PluginDisableOptions) error {
  426. return d.apiClient.PluginDisable(ctx, name, options)
  427. }
  428. func (d *DryRunClient) PluginInstall(ctx context.Context, name string, options moby.PluginInstallOptions) (io.ReadCloser, error) {
  429. return d.apiClient.PluginInstall(ctx, name, options)
  430. }
  431. func (d *DryRunClient) PluginUpgrade(ctx context.Context, name string, options moby.PluginInstallOptions) (io.ReadCloser, error) {
  432. return d.apiClient.PluginUpgrade(ctx, name, options)
  433. }
  434. func (d *DryRunClient) PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) {
  435. return d.apiClient.PluginPush(ctx, name, registryAuth)
  436. }
  437. func (d *DryRunClient) PluginSet(ctx context.Context, name string, args []string) error {
  438. return d.apiClient.PluginSet(ctx, name, args)
  439. }
  440. func (d *DryRunClient) PluginInspectWithRaw(ctx context.Context, name string) (*moby.Plugin, []byte, error) {
  441. return d.apiClient.PluginInspectWithRaw(ctx, name)
  442. }
  443. func (d *DryRunClient) PluginCreate(ctx context.Context, createContext io.Reader, options moby.PluginCreateOptions) error {
  444. return d.apiClient.PluginCreate(ctx, createContext, options)
  445. }
  446. func (d *DryRunClient) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
  447. return d.apiClient.ServiceCreate(ctx, service, options)
  448. }
  449. func (d *DryRunClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
  450. return d.apiClient.ServiceInspectWithRaw(ctx, serviceID, options)
  451. }
  452. func (d *DryRunClient) ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
  453. return d.apiClient.ServiceList(ctx, options)
  454. }
  455. func (d *DryRunClient) ServiceRemove(ctx context.Context, serviceID string) error {
  456. return d.apiClient.ServiceRemove(ctx, serviceID)
  457. }
  458. func (d *DryRunClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
  459. return d.apiClient.ServiceUpdate(ctx, serviceID, version, service, options)
  460. }
  461. func (d *DryRunClient) ServiceLogs(ctx context.Context, serviceID string, options containerType.LogsOptions) (io.ReadCloser, error) {
  462. return d.apiClient.ServiceLogs(ctx, serviceID, options)
  463. }
  464. func (d *DryRunClient) TaskLogs(ctx context.Context, taskID string, options containerType.LogsOptions) (io.ReadCloser, error) {
  465. return d.apiClient.TaskLogs(ctx, taskID, options)
  466. }
  467. func (d *DryRunClient) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) {
  468. return d.apiClient.TaskInspectWithRaw(ctx, taskID)
  469. }
  470. func (d *DryRunClient) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
  471. return d.apiClient.TaskList(ctx, options)
  472. }
  473. func (d *DryRunClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
  474. return d.apiClient.SwarmInit(ctx, req)
  475. }
  476. func (d *DryRunClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
  477. return d.apiClient.SwarmJoin(ctx, req)
  478. }
  479. func (d *DryRunClient) SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error) {
  480. return d.apiClient.SwarmGetUnlockKey(ctx)
  481. }
  482. func (d *DryRunClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
  483. return d.apiClient.SwarmUnlock(ctx, req)
  484. }
  485. func (d *DryRunClient) SwarmLeave(ctx context.Context, force bool) error {
  486. return d.apiClient.SwarmLeave(ctx, force)
  487. }
  488. func (d *DryRunClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
  489. return d.apiClient.SwarmInspect(ctx)
  490. }
  491. func (d *DryRunClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarmSpec swarm.Spec, flags swarm.UpdateFlags) error {
  492. return d.apiClient.SwarmUpdate(ctx, version, swarmSpec, flags)
  493. }
  494. func (d *DryRunClient) SecretList(ctx context.Context, options swarm.SecretListOptions) ([]swarm.Secret, error) {
  495. return d.apiClient.SecretList(ctx, options)
  496. }
  497. func (d *DryRunClient) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (swarm.SecretCreateResponse, error) {
  498. return d.apiClient.SecretCreate(ctx, secret)
  499. }
  500. func (d *DryRunClient) SecretRemove(ctx context.Context, id string) error {
  501. return d.apiClient.SecretRemove(ctx, id)
  502. }
  503. func (d *DryRunClient) SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error) {
  504. return d.apiClient.SecretInspectWithRaw(ctx, name)
  505. }
  506. func (d *DryRunClient) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error {
  507. return d.apiClient.SecretUpdate(ctx, id, version, secret)
  508. }
  509. func (d *DryRunClient) Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error) {
  510. return d.apiClient.Events(ctx, options)
  511. }
  512. func (d *DryRunClient) Info(ctx context.Context) (system.Info, error) {
  513. return d.apiClient.Info(ctx)
  514. }
  515. func (d *DryRunClient) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) {
  516. return d.apiClient.RegistryLogin(ctx, auth)
  517. }
  518. func (d *DryRunClient) DiskUsage(ctx context.Context, options moby.DiskUsageOptions) (moby.DiskUsage, error) {
  519. return d.apiClient.DiskUsage(ctx, options)
  520. }
  521. func (d *DryRunClient) Ping(ctx context.Context) (moby.Ping, error) {
  522. return d.apiClient.Ping(ctx)
  523. }
  524. func (d *DryRunClient) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) {
  525. return d.apiClient.VolumeInspect(ctx, volumeID)
  526. }
  527. func (d *DryRunClient) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) {
  528. return d.apiClient.VolumeInspectWithRaw(ctx, volumeID)
  529. }
  530. func (d *DryRunClient) VolumeList(ctx context.Context, opts volume.ListOptions) (volume.ListResponse, error) {
  531. return d.apiClient.VolumeList(ctx, opts)
  532. }
  533. func (d *DryRunClient) VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error) {
  534. return d.apiClient.VolumesPrune(ctx, pruneFilter)
  535. }
  536. func (d *DryRunClient) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error {
  537. return d.apiClient.VolumeUpdate(ctx, volumeID, version, options)
  538. }
  539. func (d *DryRunClient) ClientVersion() string {
  540. return d.apiClient.ClientVersion()
  541. }
  542. func (d *DryRunClient) DaemonHost() string {
  543. return d.apiClient.DaemonHost()
  544. }
  545. func (d *DryRunClient) HTTPClient() *http.Client {
  546. return d.apiClient.HTTPClient()
  547. }
  548. func (d *DryRunClient) ServerVersion(ctx context.Context) (moby.Version, error) {
  549. return d.apiClient.ServerVersion(ctx)
  550. }
  551. func (d *DryRunClient) NegotiateAPIVersion(ctx context.Context) {
  552. d.apiClient.NegotiateAPIVersion(ctx)
  553. }
  554. func (d *DryRunClient) NegotiateAPIVersionPing(ping moby.Ping) {
  555. d.apiClient.NegotiateAPIVersionPing(ping)
  556. }
  557. func (d *DryRunClient) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) {
  558. return d.apiClient.DialHijack(ctx, url, proto, meta)
  559. }
  560. func (d *DryRunClient) Dialer() func(context.Context) (net.Conn, error) {
  561. return d.apiClient.Dialer()
  562. }
  563. func (d *DryRunClient) Close() error {
  564. return d.apiClient.Close()
  565. }
  566. func (d *DryRunClient) CheckpointCreate(ctx context.Context, container string, options checkpoint.CreateOptions) error {
  567. return d.apiClient.CheckpointCreate(ctx, container, options)
  568. }
  569. func (d *DryRunClient) CheckpointDelete(ctx context.Context, container string, options checkpoint.DeleteOptions) error {
  570. return d.apiClient.CheckpointDelete(ctx, container, options)
  571. }
  572. func (d *DryRunClient) CheckpointList(ctx context.Context, container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) {
  573. return d.apiClient.CheckpointList(ctx, container, options)
  574. }