dryrunclient.go 25 KB

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