dryrunclient.go 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  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. "context"
  16. "io"
  17. "net"
  18. "net/http"
  19. moby "github.com/docker/docker/api/types"
  20. containerType "github.com/docker/docker/api/types/container"
  21. "github.com/docker/docker/api/types/events"
  22. "github.com/docker/docker/api/types/filters"
  23. "github.com/docker/docker/api/types/image"
  24. "github.com/docker/docker/api/types/network"
  25. "github.com/docker/docker/api/types/registry"
  26. "github.com/docker/docker/api/types/swarm"
  27. "github.com/docker/docker/api/types/volume"
  28. "github.com/docker/docker/client"
  29. specs "github.com/opencontainers/image-spec/specs-go/v1"
  30. )
  31. var _ client.APIClient = &DryRunClient{}
  32. // DryRunClient implements APIClient by delegating to implementation functions. This allows lazy init and per-method overrides
  33. type DryRunClient struct {
  34. CopyFromContainerFn func(ctx context.Context, container, srcPath string) (io.ReadCloser, moby.ContainerPathStat, error)
  35. CopyToContainerFn func(ctx context.Context, container, path string, content io.Reader, options moby.CopyToContainerOptions) error
  36. ContainersPruneFn func(ctx context.Context, pruneFilters filters.Args) (moby.ContainersPruneReport, error)
  37. ConfigListFn func(ctx context.Context, options moby.ConfigListOptions) ([]swarm.Config, error)
  38. ConfigCreateFn func(ctx context.Context, config swarm.ConfigSpec) (moby.ConfigCreateResponse, error)
  39. ConfigRemoveFn func(ctx context.Context, id string) error
  40. ConfigInspectWithRawFn func(ctx context.Context, name string) (swarm.Config, []byte, error)
  41. ConfigUpdateFn func(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error
  42. ContainerAttachFn func(ctx context.Context, container string, options moby.ContainerAttachOptions) (moby.HijackedResponse, error)
  43. ContainerCommitFn func(ctx context.Context, container string, options moby.ContainerCommitOptions) (moby.IDResponse, error)
  44. ContainerCreateFn func(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig,
  45. networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (containerType.CreateResponse, error)
  46. ContainerDiffFn func(ctx context.Context, container string) ([]containerType.ContainerChangeResponseItem, error)
  47. ContainerExecAttachFn func(ctx context.Context, execID string, config moby.ExecStartCheck) (moby.HijackedResponse, error)
  48. ContainerExecCreateFn func(ctx context.Context, container string, config moby.ExecConfig) (moby.IDResponse, error)
  49. ContainerExecInspectFn func(ctx context.Context, execID string) (moby.ContainerExecInspect, error)
  50. ContainerExecResizeFn func(ctx context.Context, execID string, options moby.ResizeOptions) error
  51. ContainerExecStartFn func(ctx context.Context, execID string, config moby.ExecStartCheck) error
  52. ContainerExportFn func(ctx context.Context, container string) (io.ReadCloser, error)
  53. ContainerInspectFn func(ctx context.Context, container string) (moby.ContainerJSON, error)
  54. ContainerInspectWithRawFn func(ctx context.Context, container string, getSize bool) (moby.ContainerJSON, []byte, error)
  55. ContainerKillFn func(ctx context.Context, container, signal string) error
  56. ContainerListFn func(ctx context.Context, options moby.ContainerListOptions) ([]moby.Container, error)
  57. ContainerLogsFn func(ctx context.Context, container string, options moby.ContainerLogsOptions) (io.ReadCloser, error)
  58. ContainerPauseFn func(ctx context.Context, container string) error
  59. ContainerRemoveFn func(ctx context.Context, container string, options moby.ContainerRemoveOptions) error
  60. ContainerRenameFn func(ctx context.Context, container, newContainerName string) error
  61. ContainerResizeFn func(ctx context.Context, container string, options moby.ResizeOptions) error
  62. ContainerRestartFn func(ctx context.Context, container string, options containerType.StopOptions) error
  63. ContainerStatPathFn func(ctx context.Context, container, path string) (moby.ContainerPathStat, error)
  64. ContainerStatsFn func(ctx context.Context, container string, stream bool) (moby.ContainerStats, error)
  65. ContainerStatsOneShotFn func(ctx context.Context, container string) (moby.ContainerStats, error)
  66. ContainerStartFn func(ctx context.Context, container string, options moby.ContainerStartOptions) error
  67. ContainerStopFn func(ctx context.Context, container string, options containerType.StopOptions) error
  68. ContainerTopFn func(ctx context.Context, container string, arguments []string) (containerType.ContainerTopOKBody, error)
  69. ContainerUnpauseFn func(ctx context.Context, container string) error
  70. ContainerUpdateFn func(ctx context.Context, container string, updateConfig containerType.UpdateConfig) (containerType.ContainerUpdateOKBody, error)
  71. ContainerWaitFn func(ctx context.Context, container string, condition containerType.WaitCondition) (<-chan containerType.WaitResponse, <-chan error)
  72. DistributionInspectFn func(ctx context.Context, imageName, encodedRegistryAuth string) (registry.DistributionInspect, error)
  73. ImageBuildFn func(ctx context.Context, reader io.Reader, options moby.ImageBuildOptions) (moby.ImageBuildResponse, error)
  74. BuildCachePruneFn func(ctx context.Context, opts moby.BuildCachePruneOptions) (*moby.BuildCachePruneReport, error)
  75. BuildCancelFn func(ctx context.Context, id string) error
  76. ImageCreateFn func(ctx context.Context, parentReference string, options moby.ImageCreateOptions) (io.ReadCloser, error)
  77. ImageHistoryFn func(ctx context.Context, imageName string) ([]image.HistoryResponseItem, error)
  78. ImageImportFn func(ctx context.Context, source moby.ImageImportSource, ref string, options moby.ImageImportOptions) (io.ReadCloser, error)
  79. ImageInspectWithRawFn func(ctx context.Context, imageName string) (moby.ImageInspect, []byte, error)
  80. ImageListFn func(ctx context.Context, options moby.ImageListOptions) ([]moby.ImageSummary, error)
  81. ImageLoadFn func(ctx context.Context, input io.Reader, quiet bool) (moby.ImageLoadResponse, error)
  82. ImagePullFn func(ctx context.Context, ref string, options moby.ImagePullOptions) (io.ReadCloser, error)
  83. ImagePushFn func(ctx context.Context, ref string, options moby.ImagePushOptions) (io.ReadCloser, error)
  84. ImageRemoveFn func(ctx context.Context, image string, options moby.ImageRemoveOptions) ([]moby.ImageDeleteResponseItem, error)
  85. ImageSearchFn func(ctx context.Context, term string, options moby.ImageSearchOptions) ([]registry.SearchResult, error)
  86. ImageSaveFn func(ctx context.Context, images []string) (io.ReadCloser, error)
  87. ImageTagFn func(ctx context.Context, image, ref string) error
  88. ImagesPruneFn func(ctx context.Context, pruneFilter filters.Args) (moby.ImagesPruneReport, error)
  89. NodeInspectWithRawFn func(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
  90. NodeListFn func(ctx context.Context, options moby.NodeListOptions) ([]swarm.Node, error)
  91. NodeRemoveFn func(ctx context.Context, nodeID string, options moby.NodeRemoveOptions) error
  92. NodeUpdateFn func(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
  93. NetworkConnectFn func(ctx context.Context, network, container string, config *network.EndpointSettings) error
  94. NetworkCreateFn func(ctx context.Context, name string, options moby.NetworkCreate) (moby.NetworkCreateResponse, error)
  95. NetworkDisconnectFn func(ctx context.Context, network, container string, force bool) error
  96. NetworkInspectFn func(ctx context.Context, network string, options moby.NetworkInspectOptions) (moby.NetworkResource, error)
  97. NetworkInspectWithRawFn func(ctx context.Context, network string, options moby.NetworkInspectOptions) (moby.NetworkResource, []byte, error)
  98. NetworkListFn func(ctx context.Context, options moby.NetworkListOptions) ([]moby.NetworkResource, error)
  99. NetworkRemoveFn func(ctx context.Context, network string) error
  100. NetworksPruneFn func(ctx context.Context, pruneFilter filters.Args) (moby.NetworksPruneReport, error)
  101. PluginListFn func(ctx context.Context, filter filters.Args) (moby.PluginsListResponse, error)
  102. PluginRemoveFn func(ctx context.Context, name string, options moby.PluginRemoveOptions) error
  103. PluginEnableFn func(ctx context.Context, name string, options moby.PluginEnableOptions) error
  104. PluginDisableFn func(ctx context.Context, name string, options moby.PluginDisableOptions) error
  105. PluginInstallFn func(ctx context.Context, name string, options moby.PluginInstallOptions) (io.ReadCloser, error)
  106. PluginUpgradeFn func(ctx context.Context, name string, options moby.PluginInstallOptions) (io.ReadCloser, error)
  107. PluginPushFn func(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error)
  108. PluginSetFn func(ctx context.Context, name string, args []string) error
  109. PluginInspectWithRawFn func(ctx context.Context, name string) (*moby.Plugin, []byte, error)
  110. PluginCreateFn func(ctx context.Context, createContext io.Reader, options moby.PluginCreateOptions) error
  111. ServiceCreateFn func(ctx context.Context, service swarm.ServiceSpec, options moby.ServiceCreateOptions) (moby.ServiceCreateResponse, error)
  112. ServiceInspectWithRawFn func(ctx context.Context, serviceID string, options moby.ServiceInspectOptions) (swarm.Service, []byte, error)
  113. ServiceListFn func(ctx context.Context, options moby.ServiceListOptions) ([]swarm.Service, error)
  114. ServiceRemoveFn func(ctx context.Context, serviceID string) error
  115. ServiceUpdateFn func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options moby.ServiceUpdateOptions) (moby.ServiceUpdateResponse, error)
  116. ServiceLogsFn func(ctx context.Context, serviceID string, options moby.ContainerLogsOptions) (io.ReadCloser, error)
  117. TaskLogsFn func(ctx context.Context, taskID string, options moby.ContainerLogsOptions) (io.ReadCloser, error)
  118. TaskInspectWithRawFn func(ctx context.Context, taskID string) (swarm.Task, []byte, error)
  119. TaskListFn func(ctx context.Context, options moby.TaskListOptions) ([]swarm.Task, error)
  120. SwarmInitFn func(ctx context.Context, req swarm.InitRequest) (string, error)
  121. SwarmJoinFn func(ctx context.Context, req swarm.JoinRequest) error
  122. SwarmGetUnlockKeyFn func(ctx context.Context) (moby.SwarmUnlockKeyResponse, error)
  123. SwarmUnlockFn func(ctx context.Context, req swarm.UnlockRequest) error
  124. SwarmLeaveFn func(ctx context.Context, force bool) error
  125. SwarmInspectFn func(ctx context.Context) (swarm.Swarm, error)
  126. SwarmUpdateFn func(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
  127. SecretListFn func(ctx context.Context, options moby.SecretListOptions) ([]swarm.Secret, error)
  128. SecretCreateFn func(ctx context.Context, secret swarm.SecretSpec) (moby.SecretCreateResponse, error)
  129. SecretRemoveFn func(ctx context.Context, id string) error
  130. SecretInspectWithRawFn func(ctx context.Context, name string) (swarm.Secret, []byte, error)
  131. SecretUpdateFn func(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
  132. EventsFn func(ctx context.Context, options moby.EventsOptions) (<-chan events.Message, <-chan error)
  133. InfoFn func(ctx context.Context) (moby.Info, error)
  134. RegistryLoginFn func(ctx context.Context, auth moby.AuthConfig) (registry.AuthenticateOKBody, error)
  135. DiskUsageFn func(ctx context.Context, options moby.DiskUsageOptions) (moby.DiskUsage, error)
  136. PingFn func(ctx context.Context) (moby.Ping, error)
  137. VolumeCreateFn func(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
  138. VolumeInspectFn func(ctx context.Context, volumeID string) (volume.Volume, error)
  139. VolumeInspectWithRawFn func(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
  140. VolumeListFn func(ctx context.Context, filter filters.Args) (volume.ListResponse, error)
  141. VolumeRemoveFn func(ctx context.Context, volumeID string, force bool) error
  142. VolumesPruneFn func(ctx context.Context, pruneFilter filters.Args) (moby.VolumesPruneReport, error)
  143. VolumeUpdateFn func(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error
  144. ClientVersionFn func() string
  145. DaemonHostFn func() string
  146. HTTPClientFn func() *http.Client
  147. ServerVersionFn func(ctx context.Context) (moby.Version, error)
  148. NegotiateAPIVersionFn func(ctx context.Context)
  149. NegotiateAPIVersionPingFn func(ping moby.Ping)
  150. DialHijackFn func(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error)
  151. DialerFn func() func(context.Context) (net.Conn, error)
  152. CloseFn func() error
  153. CheckpointCreateFn func(ctx context.Context, container string, options moby.CheckpointCreateOptions) error
  154. CheckpointDeleteFn func(ctx context.Context, container string, options moby.CheckpointDeleteOptions) error
  155. CheckpointListFn func(ctx context.Context, container string, options moby.CheckpointListOptions) ([]moby.Checkpoint, error)
  156. }
  157. // NewDryRunClient produces a DryRunClient
  158. func NewDryRunClient() *DryRunClient {
  159. return &DryRunClient{}
  160. }
  161. // WithAPIClient configure DryRunClient to use specified APIClient as delegate
  162. func (d *DryRunClient) WithAPIClient(apiClient client.APIClient) {
  163. d.ConfigListFn = apiClient.ConfigList
  164. d.ConfigCreateFn = apiClient.ConfigCreate
  165. d.ConfigRemoveFn = apiClient.ConfigRemove
  166. d.ConfigInspectWithRawFn = apiClient.ConfigInspectWithRaw
  167. d.ConfigUpdateFn = apiClient.ConfigUpdate
  168. d.ContainerAttachFn = apiClient.ContainerAttach
  169. d.ContainerCommitFn = apiClient.ContainerCommit
  170. d.ContainerCreateFn = apiClient.ContainerCreate
  171. d.ContainerDiffFn = apiClient.ContainerDiff
  172. d.ContainerExecAttachFn = apiClient.ContainerExecAttach
  173. d.ContainerExecCreateFn = apiClient.ContainerExecCreate
  174. d.ContainerExecInspectFn = apiClient.ContainerExecInspect
  175. d.ContainerExecResizeFn = apiClient.ContainerExecResize
  176. d.ContainerExecStartFn = apiClient.ContainerExecStart
  177. d.ContainerExportFn = apiClient.ContainerExport
  178. d.ContainerInspectFn = apiClient.ContainerInspect
  179. d.ContainerInspectWithRawFn = apiClient.ContainerInspectWithRaw
  180. d.ContainerKillFn = apiClient.ContainerKill
  181. d.ContainerListFn = apiClient.ContainerList
  182. d.ContainerLogsFn = apiClient.ContainerLogs
  183. d.ContainerPauseFn = apiClient.ContainerPause
  184. d.ContainerRemoveFn = apiClient.ContainerRemove
  185. d.ContainerRenameFn = apiClient.ContainerRename
  186. d.ContainerResizeFn = apiClient.ContainerResize
  187. d.ContainerRestartFn = apiClient.ContainerRestart
  188. d.ContainerStatPathFn = apiClient.ContainerStatPath
  189. d.ContainerStatsFn = apiClient.ContainerStats
  190. d.ContainerStatsOneShotFn = apiClient.ContainerStatsOneShot
  191. d.ContainerStartFn = apiClient.ContainerStart
  192. d.ContainerStopFn = apiClient.ContainerStop
  193. d.ContainerTopFn = apiClient.ContainerTop
  194. d.ContainerUnpauseFn = apiClient.ContainerUnpause
  195. d.ContainerUpdateFn = apiClient.ContainerUpdate
  196. d.ContainerWaitFn = apiClient.ContainerWait
  197. d.DistributionInspectFn = apiClient.DistributionInspect
  198. d.ImageBuildFn = apiClient.ImageBuild
  199. d.BuildCachePruneFn = apiClient.BuildCachePrune
  200. d.BuildCancelFn = apiClient.BuildCancel
  201. d.ImageCreateFn = apiClient.ImageCreate
  202. d.ImageHistoryFn = apiClient.ImageHistory
  203. d.ImageImportFn = apiClient.ImageImport
  204. d.ImageInspectWithRawFn = apiClient.ImageInspectWithRaw
  205. d.ImageListFn = apiClient.ImageList
  206. d.ImageLoadFn = apiClient.ImageLoad
  207. d.ImagePullFn = apiClient.ImagePull
  208. d.ImagePushFn = apiClient.ImagePush
  209. d.ImageRemoveFn = apiClient.ImageRemove
  210. d.ImageSearchFn = apiClient.ImageSearch
  211. d.ImageSaveFn = apiClient.ImageSave
  212. d.ImageTagFn = apiClient.ImageTag
  213. d.ImagesPruneFn = apiClient.ImagesPrune
  214. d.NodeInspectWithRawFn = apiClient.NodeInspectWithRaw
  215. d.NodeListFn = apiClient.NodeList
  216. d.NodeRemoveFn = apiClient.NodeRemove
  217. d.NodeUpdateFn = apiClient.NodeUpdate
  218. d.NetworkConnectFn = apiClient.NetworkConnect
  219. d.NetworkCreateFn = apiClient.NetworkCreate
  220. d.NetworkDisconnectFn = apiClient.NetworkDisconnect
  221. d.NetworkInspectFn = apiClient.NetworkInspect
  222. d.NetworkInspectWithRawFn = apiClient.NetworkInspectWithRaw
  223. d.NetworkListFn = apiClient.NetworkList
  224. d.NetworkRemoveFn = apiClient.NetworkRemove
  225. d.NetworksPruneFn = apiClient.NetworksPrune
  226. d.PluginListFn = apiClient.PluginList
  227. d.PluginRemoveFn = apiClient.PluginRemove
  228. d.PluginEnableFn = apiClient.PluginEnable
  229. d.PluginDisableFn = apiClient.PluginDisable
  230. d.PluginInstallFn = apiClient.PluginInstall
  231. d.PluginUpgradeFn = apiClient.PluginUpgrade
  232. d.PluginPushFn = apiClient.PluginPush
  233. d.PluginSetFn = apiClient.PluginSet
  234. d.PluginInspectWithRawFn = apiClient.PluginInspectWithRaw
  235. d.PluginCreateFn = apiClient.PluginCreate
  236. d.ServiceCreateFn = apiClient.ServiceCreate
  237. d.ServiceInspectWithRawFn = apiClient.ServiceInspectWithRaw
  238. d.ServiceListFn = apiClient.ServiceList
  239. d.ServiceRemoveFn = apiClient.ServiceRemove
  240. d.ServiceUpdateFn = apiClient.ServiceUpdate
  241. d.ServiceLogsFn = apiClient.ServiceLogs
  242. d.TaskLogsFn = apiClient.TaskLogs
  243. d.TaskInspectWithRawFn = apiClient.TaskInspectWithRaw
  244. d.TaskListFn = apiClient.TaskList
  245. d.SwarmInitFn = apiClient.SwarmInit
  246. d.SwarmJoinFn = apiClient.SwarmJoin
  247. d.SwarmGetUnlockKeyFn = apiClient.SwarmGetUnlockKey
  248. d.SwarmUnlockFn = apiClient.SwarmUnlock
  249. d.SwarmLeaveFn = apiClient.SwarmLeave
  250. d.SwarmInspectFn = apiClient.SwarmInspect
  251. d.SwarmUpdateFn = apiClient.SwarmUpdate
  252. d.SecretListFn = apiClient.SecretList
  253. d.SecretCreateFn = apiClient.SecretCreate
  254. d.SecretRemoveFn = apiClient.SecretRemove
  255. d.SecretInspectWithRawFn = apiClient.SecretInspectWithRaw
  256. d.SecretUpdateFn = apiClient.SecretUpdate
  257. d.EventsFn = apiClient.Events
  258. d.InfoFn = apiClient.Info
  259. d.RegistryLoginFn = apiClient.RegistryLogin
  260. d.DiskUsageFn = apiClient.DiskUsage
  261. d.PingFn = apiClient.Ping
  262. d.VolumeCreateFn = apiClient.VolumeCreate
  263. d.VolumeInspectFn = apiClient.VolumeInspect
  264. d.VolumeInspectWithRawFn = apiClient.VolumeInspectWithRaw
  265. d.VolumeListFn = apiClient.VolumeList
  266. d.VolumeRemoveFn = apiClient.VolumeRemove
  267. d.VolumesPruneFn = apiClient.VolumesPrune
  268. d.VolumeUpdateFn = apiClient.VolumeUpdate
  269. d.ClientVersionFn = apiClient.ClientVersion
  270. d.DaemonHostFn = apiClient.DaemonHost
  271. d.HTTPClientFn = apiClient.HTTPClient
  272. d.ServerVersionFn = apiClient.ServerVersion
  273. d.NegotiateAPIVersionFn = apiClient.NegotiateAPIVersion
  274. d.NegotiateAPIVersionPingFn = apiClient.NegotiateAPIVersionPing
  275. d.DialHijackFn = apiClient.DialHijack
  276. d.DialerFn = apiClient.Dialer
  277. d.CloseFn = apiClient.Close
  278. d.CheckpointCreateFn = apiClient.CheckpointCreate
  279. d.CheckpointDeleteFn = apiClient.CheckpointDelete
  280. d.CheckpointListFn = apiClient.CheckpointList
  281. }
  282. // All methods and functions which need to be overridden for dry run.
  283. func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options moby.ContainerAttachOptions) (moby.HijackedResponse, error) {
  284. return moby.HijackedResponse{}, ErrNotImplemented
  285. }
  286. func (d *DryRunClient) ContainerCreate(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig,
  287. networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (containerType.CreateResponse, error) {
  288. return containerType.CreateResponse{}, ErrNotImplemented
  289. }
  290. func (d *DryRunClient) ContainerKill(ctx context.Context, container, signal string) error {
  291. return ErrNotImplemented
  292. }
  293. func (d *DryRunClient) ContainerPause(ctx context.Context, container string) error {
  294. return ErrNotImplemented
  295. }
  296. func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options moby.ContainerRemoveOptions) error {
  297. return ErrNotImplemented
  298. }
  299. func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error {
  300. return ErrNotImplemented
  301. }
  302. func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, options containerType.StopOptions) error {
  303. return ErrNotImplemented
  304. }
  305. func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options moby.ContainerStartOptions) error {
  306. return ErrNotImplemented
  307. }
  308. func (d *DryRunClient) ContainerStop(ctx context.Context, container string, options containerType.StopOptions) error {
  309. return ErrNotImplemented
  310. }
  311. func (d *DryRunClient) ContainerUnpause(ctx context.Context, container string) error {
  312. return ErrNotImplemented
  313. }
  314. func (d *DryRunClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, moby.ContainerPathStat, error) {
  315. return nil, moby.ContainerPathStat{}, ErrNotImplemented
  316. }
  317. func (d *DryRunClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options moby.CopyToContainerOptions) error {
  318. return ErrNotImplemented
  319. }
  320. func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options moby.ImageBuildOptions) (moby.ImageBuildResponse, error) {
  321. return moby.ImageBuildResponse{}, ErrNotImplemented
  322. }
  323. func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options moby.ImagePullOptions) (io.ReadCloser, error) {
  324. return nil, ErrNotImplemented
  325. }
  326. func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options moby.ImagePushOptions) (io.ReadCloser, error) {
  327. return nil, ErrNotImplemented
  328. }
  329. func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options moby.ImageRemoveOptions) ([]moby.ImageDeleteResponseItem, error) {
  330. return nil, ErrNotImplemented
  331. }
  332. func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, container string, config *network.EndpointSettings) error {
  333. return ErrNotImplemented
  334. }
  335. func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options moby.NetworkCreate) (moby.NetworkCreateResponse, error) {
  336. return moby.NetworkCreateResponse{}, ErrNotImplemented
  337. }
  338. func (d *DryRunClient) NetworkDisconnect(ctx context.Context, networkName, container string, force bool) error {
  339. return ErrNotImplemented
  340. }
  341. func (d *DryRunClient) NetworkRemove(ctx context.Context, networkName string) error {
  342. return ErrNotImplemented
  343. }
  344. func (d *DryRunClient) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
  345. return volume.Volume{}, ErrNotImplemented
  346. }
  347. func (d *DryRunClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
  348. return ErrNotImplemented
  349. }
  350. // Functions delegated to original APIClient (not used by Compose or not modifying the Compose stack
  351. func (d *DryRunClient) ConfigList(ctx context.Context, options moby.ConfigListOptions) ([]swarm.Config, error) {
  352. if d.ConfigListFn == nil {
  353. return nil, ErrNotImplemented
  354. }
  355. return d.ConfigListFn(ctx, options)
  356. }
  357. func (d *DryRunClient) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (moby.ConfigCreateResponse, error) {
  358. if d.ConfigCreateFn == nil {
  359. return moby.ConfigCreateResponse{}, ErrNotImplemented
  360. }
  361. return d.ConfigCreateFn(ctx, config)
  362. }
  363. func (d *DryRunClient) ConfigRemove(ctx context.Context, id string) error {
  364. if d.ConfigRemoveFn == nil {
  365. return ErrNotImplemented
  366. }
  367. return d.ConfigRemoveFn(ctx, id)
  368. }
  369. func (d *DryRunClient) ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error) {
  370. if d.ConfigInspectWithRawFn == nil {
  371. return swarm.Config{}, nil, ErrNotImplemented
  372. }
  373. return d.ConfigInspectWithRawFn(ctx, name)
  374. }
  375. func (d *DryRunClient) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error {
  376. if d.ConfigUpdateFn == nil {
  377. return ErrNotImplemented
  378. }
  379. return d.ConfigUpdateFn(ctx, id, version, config)
  380. }
  381. func (d *DryRunClient) ContainerCommit(ctx context.Context, container string, options moby.ContainerCommitOptions) (moby.IDResponse, error) {
  382. if d.ContainerCommitFn == nil {
  383. return moby.IDResponse{}, ErrNotImplemented
  384. }
  385. return d.ContainerCommitFn(ctx, container, options)
  386. }
  387. func (d *DryRunClient) ContainerDiff(ctx context.Context, container string) ([]containerType.ContainerChangeResponseItem, error) {
  388. if d.ContainerDiffFn == nil {
  389. return nil, ErrNotImplemented
  390. }
  391. return d.ContainerDiffFn(ctx, container)
  392. }
  393. func (d *DryRunClient) ContainerExecAttach(ctx context.Context, execID string, config moby.ExecStartCheck) (moby.HijackedResponse, error) {
  394. if d.ContainerExecAttachFn == nil {
  395. return moby.HijackedResponse{}, ErrNotImplemented
  396. }
  397. return d.ContainerExecAttachFn(ctx, execID, config)
  398. }
  399. func (d *DryRunClient) ContainerExecCreate(ctx context.Context, container string, config moby.ExecConfig) (moby.IDResponse, error) {
  400. if d.ContainerExecCreateFn == nil {
  401. return moby.IDResponse{}, ErrNotImplemented
  402. }
  403. return d.ContainerExecCreateFn(ctx, container, config)
  404. }
  405. func (d *DryRunClient) ContainerExecInspect(ctx context.Context, execID string) (moby.ContainerExecInspect, error) {
  406. if d.ContainerExecInspectFn == nil {
  407. return moby.ContainerExecInspect{}, ErrNotImplemented
  408. }
  409. return d.ContainerExecInspectFn(ctx, execID)
  410. }
  411. func (d *DryRunClient) ContainerExecResize(ctx context.Context, execID string, options moby.ResizeOptions) error {
  412. if d.ContainerExecResizeFn == nil {
  413. return ErrNotImplemented
  414. }
  415. return d.ContainerExecResizeFn(ctx, execID, options)
  416. }
  417. func (d *DryRunClient) ContainerExecStart(ctx context.Context, execID string, config moby.ExecStartCheck) error {
  418. if d.ContainerExecStartFn == nil {
  419. return ErrNotImplemented
  420. }
  421. return d.ContainerExecStartFn(ctx, execID, config)
  422. }
  423. func (d *DryRunClient) ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) {
  424. if d.ContainerExportFn == nil {
  425. return nil, ErrNotImplemented
  426. }
  427. return d.ContainerExportFn(ctx, container)
  428. }
  429. func (d *DryRunClient) ContainerInspect(ctx context.Context, container string) (moby.ContainerJSON, error) {
  430. if d.ContainerInspectFn == nil {
  431. return moby.ContainerJSON{}, ErrNotImplemented
  432. }
  433. return d.ContainerInspectFn(ctx, container)
  434. }
  435. func (d *DryRunClient) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (moby.ContainerJSON, []byte, error) {
  436. if d.ContainerInspectWithRawFn == nil {
  437. return moby.ContainerJSON{}, nil, ErrNotImplemented
  438. }
  439. return d.ContainerInspectWithRawFn(ctx, container, getSize)
  440. }
  441. func (d *DryRunClient) ContainerList(ctx context.Context, options moby.ContainerListOptions) ([]moby.Container, error) {
  442. if d.ContainerListFn == nil {
  443. return nil, ErrNotImplemented
  444. }
  445. return d.ContainerListFn(ctx, options)
  446. }
  447. func (d *DryRunClient) ContainerLogs(ctx context.Context, container string, options moby.ContainerLogsOptions) (io.ReadCloser, error) {
  448. if d.ContainerLogsFn == nil {
  449. return nil, ErrNotImplemented
  450. }
  451. return d.ContainerLogsFn(ctx, container, options)
  452. }
  453. func (d *DryRunClient) ContainerResize(ctx context.Context, container string, options moby.ResizeOptions) error {
  454. if d.ContainerResizeFn == nil {
  455. return ErrNotImplemented
  456. }
  457. return d.ContainerResizeFn(ctx, container, options)
  458. }
  459. func (d *DryRunClient) ContainerStatPath(ctx context.Context, container, path string) (moby.ContainerPathStat, error) {
  460. if d.ContainerStatPathFn == nil {
  461. return moby.ContainerPathStat{}, ErrNotImplemented
  462. }
  463. return d.ContainerStatPathFn(ctx, container, path)
  464. }
  465. func (d *DryRunClient) ContainerStats(ctx context.Context, container string, stream bool) (moby.ContainerStats, error) {
  466. if d.ContainerStatsFn == nil {
  467. return moby.ContainerStats{}, ErrNotImplemented
  468. }
  469. return d.ContainerStatsFn(ctx, container, stream)
  470. }
  471. func (d *DryRunClient) ContainerStatsOneShot(ctx context.Context, container string) (moby.ContainerStats, error) {
  472. if d.ContainerStatsOneShotFn == nil {
  473. return moby.ContainerStats{}, ErrNotImplemented
  474. }
  475. return d.ContainerStatsOneShotFn(ctx, container)
  476. }
  477. func (d *DryRunClient) ContainerTop(ctx context.Context, container string, arguments []string) (containerType.ContainerTopOKBody, error) {
  478. if d.ContainerTopFn == nil {
  479. return containerType.ContainerTopOKBody{}, ErrNotImplemented
  480. }
  481. return d.ContainerTopFn(ctx, container, arguments)
  482. }
  483. func (d *DryRunClient) ContainerUpdate(ctx context.Context, container string, updateConfig containerType.UpdateConfig) (containerType.ContainerUpdateOKBody, error) {
  484. if d.ContainerUpdateFn == nil {
  485. return containerType.ContainerUpdateOKBody{}, ErrNotImplemented
  486. }
  487. return d.ContainerUpdateFn(ctx, container, updateConfig)
  488. }
  489. func (d *DryRunClient) ContainerWait(ctx context.Context, container string, condition containerType.WaitCondition) (<-chan containerType.WaitResponse, <-chan error) {
  490. if d.ContainerWaitFn == nil {
  491. errC := make(chan error, 1)
  492. errC <- ErrNotImplemented
  493. return nil, errC
  494. }
  495. return d.ContainerWaitFn(ctx, container, condition)
  496. }
  497. func (d *DryRunClient) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (moby.ContainersPruneReport, error) {
  498. if d.ContainersPruneFn == nil {
  499. return moby.ContainersPruneReport{}, ErrNotImplemented
  500. }
  501. return d.ContainersPruneFn(ctx, pruneFilters)
  502. }
  503. func (d *DryRunClient) DistributionInspect(ctx context.Context, imageName, encodedRegistryAuth string) (registry.DistributionInspect, error) {
  504. if d.DistributionInspectFn == nil {
  505. return registry.DistributionInspect{}, ErrNotImplemented
  506. }
  507. return d.DistributionInspectFn(ctx, imageName, encodedRegistryAuth)
  508. }
  509. func (d *DryRunClient) BuildCachePrune(ctx context.Context, opts moby.BuildCachePruneOptions) (*moby.BuildCachePruneReport, error) {
  510. if d.BuildCachePruneFn == nil {
  511. return nil, ErrNotImplemented
  512. }
  513. return d.BuildCachePruneFn(ctx, opts)
  514. }
  515. func (d *DryRunClient) BuildCancel(ctx context.Context, id string) error {
  516. if d.BuildCancelFn == nil {
  517. return ErrNotImplemented
  518. }
  519. return d.BuildCancelFn(ctx, id)
  520. }
  521. func (d *DryRunClient) ImageCreate(ctx context.Context, parentReference string, options moby.ImageCreateOptions) (io.ReadCloser, error) {
  522. if d.ImageCreateFn == nil {
  523. return nil, ErrNotImplemented
  524. }
  525. return d.ImageCreateFn(ctx, parentReference, options)
  526. }
  527. func (d *DryRunClient) ImageHistory(ctx context.Context, imageName string) ([]image.HistoryResponseItem, error) {
  528. if d.ImageHistoryFn == nil {
  529. return nil, ErrNotImplemented
  530. }
  531. return d.ImageHistoryFn(ctx, imageName)
  532. }
  533. func (d *DryRunClient) ImageImport(ctx context.Context, source moby.ImageImportSource, ref string, options moby.ImageImportOptions) (io.ReadCloser, error) {
  534. if d.ImageImportFn == nil {
  535. return nil, ErrNotImplemented
  536. }
  537. return d.ImageImportFn(ctx, source, ref, options)
  538. }
  539. func (d *DryRunClient) ImageInspectWithRaw(ctx context.Context, imageName string) (moby.ImageInspect, []byte, error) {
  540. if d.ImageInspectWithRawFn == nil {
  541. return moby.ImageInspect{}, nil, ErrNotImplemented
  542. }
  543. return d.ImageInspectWithRawFn(ctx, imageName)
  544. }
  545. func (d *DryRunClient) ImageList(ctx context.Context, options moby.ImageListOptions) ([]moby.ImageSummary, error) {
  546. if d.ImageListFn == nil {
  547. return nil, ErrNotImplemented
  548. }
  549. return d.ImageListFn(ctx, options)
  550. }
  551. func (d *DryRunClient) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (moby.ImageLoadResponse, error) {
  552. if d.ImageLoadFn == nil {
  553. return moby.ImageLoadResponse{}, ErrNotImplemented
  554. }
  555. return d.ImageLoadFn(ctx, input, quiet)
  556. }
  557. func (d *DryRunClient) ImageSearch(ctx context.Context, term string, options moby.ImageSearchOptions) ([]registry.SearchResult, error) {
  558. if d.ImageSearchFn == nil {
  559. return nil, ErrNotImplemented
  560. }
  561. return d.ImageSearchFn(ctx, term, options)
  562. }
  563. func (d *DryRunClient) ImageSave(ctx context.Context, images []string) (io.ReadCloser, error) {
  564. if d.ImageSaveFn == nil {
  565. return nil, ErrNotImplemented
  566. }
  567. return d.ImageSaveFn(ctx, images)
  568. }
  569. func (d *DryRunClient) ImageTag(ctx context.Context, imageName, ref string) error {
  570. if d.ImageTagFn == nil {
  571. return ErrNotImplemented
  572. }
  573. return d.ImageTagFn(ctx, imageName, ref)
  574. }
  575. func (d *DryRunClient) ImagesPrune(ctx context.Context, pruneFilter filters.Args) (moby.ImagesPruneReport, error) {
  576. if d.ImagesPruneFn == nil {
  577. return moby.ImagesPruneReport{}, ErrNotImplemented
  578. }
  579. return d.ImagesPruneFn(ctx, pruneFilter)
  580. }
  581. func (d *DryRunClient) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) {
  582. if d.NodeInspectWithRawFn == nil {
  583. return swarm.Node{}, nil, ErrNotImplemented
  584. }
  585. return d.NodeInspectWithRawFn(ctx, nodeID)
  586. }
  587. func (d *DryRunClient) NodeList(ctx context.Context, options moby.NodeListOptions) ([]swarm.Node, error) {
  588. if d.NodeListFn == nil {
  589. return nil, ErrNotImplemented
  590. }
  591. return d.NodeListFn(ctx, options)
  592. }
  593. func (d *DryRunClient) NodeRemove(ctx context.Context, nodeID string, options moby.NodeRemoveOptions) error {
  594. if d.NodeRemoveFn == nil {
  595. return ErrNotImplemented
  596. }
  597. return d.NodeRemoveFn(ctx, nodeID, options)
  598. }
  599. func (d *DryRunClient) NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error {
  600. if d.NodeUpdateFn == nil {
  601. return ErrNotImplemented
  602. }
  603. return d.NodeUpdateFn(ctx, nodeID, version, node)
  604. }
  605. func (d *DryRunClient) NetworkInspect(ctx context.Context, networkName string, options moby.NetworkInspectOptions) (moby.NetworkResource, error) {
  606. if d.NetworkInspectFn == nil {
  607. return moby.NetworkResource{}, ErrNotImplemented
  608. }
  609. return d.NetworkInspectFn(ctx, networkName, options)
  610. }
  611. func (d *DryRunClient) NetworkInspectWithRaw(ctx context.Context, networkName string, options moby.NetworkInspectOptions) (moby.NetworkResource, []byte, error) {
  612. if d.NetworkInspectWithRawFn == nil {
  613. return moby.NetworkResource{}, nil, ErrNotImplemented
  614. }
  615. return d.NetworkInspectWithRawFn(ctx, networkName, options)
  616. }
  617. func (d *DryRunClient) NetworkList(ctx context.Context, options moby.NetworkListOptions) ([]moby.NetworkResource, error) {
  618. if d.NetworkListFn == nil {
  619. return nil, ErrNotImplemented
  620. }
  621. return d.NetworkListFn(ctx, options)
  622. }
  623. func (d *DryRunClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (moby.NetworksPruneReport, error) {
  624. if d.NetworksPruneFn == nil {
  625. return moby.NetworksPruneReport{}, ErrNotImplemented
  626. }
  627. return d.NetworksPruneFn(ctx, pruneFilter)
  628. }
  629. func (d *DryRunClient) PluginList(ctx context.Context, filter filters.Args) (moby.PluginsListResponse, error) {
  630. if d.PluginListFn == nil {
  631. return moby.PluginsListResponse{}, ErrNotImplemented
  632. }
  633. return d.PluginListFn(ctx, filter)
  634. }
  635. func (d *DryRunClient) PluginRemove(ctx context.Context, name string, options moby.PluginRemoveOptions) error {
  636. if d.PluginRemoveFn == nil {
  637. return ErrNotImplemented
  638. }
  639. return d.PluginRemoveFn(ctx, name, options)
  640. }
  641. func (d *DryRunClient) PluginEnable(ctx context.Context, name string, options moby.PluginEnableOptions) error {
  642. if d.PluginEnableFn == nil {
  643. return ErrNotImplemented
  644. }
  645. return d.PluginEnableFn(ctx, name, options)
  646. }
  647. func (d *DryRunClient) PluginDisable(ctx context.Context, name string, options moby.PluginDisableOptions) error {
  648. if d.PluginDisableFn == nil {
  649. return ErrNotImplemented
  650. }
  651. return d.PluginDisableFn(ctx, name, options)
  652. }
  653. func (d *DryRunClient) PluginInstall(ctx context.Context, name string, options moby.PluginInstallOptions) (io.ReadCloser, error) {
  654. if d.PluginInstallFn == nil {
  655. return nil, ErrNotImplemented
  656. }
  657. return d.PluginInstallFn(ctx, name, options)
  658. }
  659. func (d *DryRunClient) PluginUpgrade(ctx context.Context, name string, options moby.PluginInstallOptions) (io.ReadCloser, error) {
  660. if d.PluginUpgradeFn == nil {
  661. return nil, ErrNotImplemented
  662. }
  663. return d.PluginUpgradeFn(ctx, name, options)
  664. }
  665. func (d *DryRunClient) PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) {
  666. if d.PluginPushFn == nil {
  667. return nil, ErrNotImplemented
  668. }
  669. return d.PluginPushFn(ctx, name, registryAuth)
  670. }
  671. func (d *DryRunClient) PluginSet(ctx context.Context, name string, args []string) error {
  672. if d.PluginSetFn == nil {
  673. return ErrNotImplemented
  674. }
  675. return d.PluginSetFn(ctx, name, args)
  676. }
  677. func (d *DryRunClient) PluginInspectWithRaw(ctx context.Context, name string) (*moby.Plugin, []byte, error) {
  678. if d.PluginInspectWithRawFn == nil {
  679. return nil, nil, ErrNotImplemented
  680. }
  681. return d.PluginInspectWithRawFn(ctx, name)
  682. }
  683. func (d *DryRunClient) PluginCreate(ctx context.Context, createContext io.Reader, options moby.PluginCreateOptions) error {
  684. if d.PluginCreateFn == nil {
  685. return ErrNotImplemented
  686. }
  687. return d.PluginCreateFn(ctx, createContext, options)
  688. }
  689. func (d *DryRunClient) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options moby.ServiceCreateOptions) (moby.ServiceCreateResponse, error) {
  690. if d.ServiceCreateFn == nil {
  691. return moby.ServiceCreateResponse{}, ErrNotImplemented
  692. }
  693. return d.ServiceCreateFn(ctx, service, options)
  694. }
  695. func (d *DryRunClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options moby.ServiceInspectOptions) (swarm.Service, []byte, error) {
  696. if d.ServiceInspectWithRawFn == nil {
  697. return swarm.Service{}, nil, ErrNotImplemented
  698. }
  699. return d.ServiceInspectWithRawFn(ctx, serviceID, options)
  700. }
  701. func (d *DryRunClient) ServiceList(ctx context.Context, options moby.ServiceListOptions) ([]swarm.Service, error) {
  702. if d.ServiceListFn == nil {
  703. return nil, ErrNotImplemented
  704. }
  705. return d.ServiceListFn(ctx, options)
  706. }
  707. func (d *DryRunClient) ServiceRemove(ctx context.Context, serviceID string) error {
  708. if d.ServiceRemoveFn == nil {
  709. return ErrNotImplemented
  710. }
  711. return d.ServiceRemoveFn(ctx, serviceID)
  712. }
  713. func (d *DryRunClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options moby.ServiceUpdateOptions) (moby.ServiceUpdateResponse, error) {
  714. if d.ServiceUpdateFn == nil {
  715. return moby.ServiceUpdateResponse{}, ErrNotImplemented
  716. }
  717. return d.ServiceUpdateFn(ctx, serviceID, version, service, options)
  718. }
  719. func (d *DryRunClient) ServiceLogs(ctx context.Context, serviceID string, options moby.ContainerLogsOptions) (io.ReadCloser, error) {
  720. if d.ServiceLogsFn == nil {
  721. return nil, ErrNotImplemented
  722. }
  723. return d.ServiceLogsFn(ctx, serviceID, options)
  724. }
  725. func (d *DryRunClient) TaskLogs(ctx context.Context, taskID string, options moby.ContainerLogsOptions) (io.ReadCloser, error) {
  726. if d.TaskLogsFn == nil {
  727. return nil, ErrNotImplemented
  728. }
  729. return d.TaskLogsFn(ctx, taskID, options)
  730. }
  731. func (d *DryRunClient) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) {
  732. if d.TaskInspectWithRawFn == nil {
  733. return swarm.Task{}, nil, ErrNotImplemented
  734. }
  735. return d.TaskInspectWithRawFn(ctx, taskID)
  736. }
  737. func (d *DryRunClient) TaskList(ctx context.Context, options moby.TaskListOptions) ([]swarm.Task, error) {
  738. if d.TaskListFn == nil {
  739. return nil, ErrNotImplemented
  740. }
  741. return d.TaskListFn(ctx, options)
  742. }
  743. func (d *DryRunClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
  744. if d.SwarmInitFn == nil {
  745. return "", ErrNotImplemented
  746. }
  747. return d.SwarmInitFn(ctx, req)
  748. }
  749. func (d *DryRunClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
  750. if d.SwarmJoinFn == nil {
  751. return ErrNotImplemented
  752. }
  753. return d.SwarmJoinFn(ctx, req)
  754. }
  755. func (d *DryRunClient) SwarmGetUnlockKey(ctx context.Context) (moby.SwarmUnlockKeyResponse, error) {
  756. if d.SwarmGetUnlockKeyFn == nil {
  757. return moby.SwarmUnlockKeyResponse{}, ErrNotImplemented
  758. }
  759. return d.SwarmGetUnlockKeyFn(ctx)
  760. }
  761. func (d *DryRunClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
  762. if d.SwarmUnlockFn == nil {
  763. return ErrNotImplemented
  764. }
  765. return d.SwarmUnlockFn(ctx, req)
  766. }
  767. func (d *DryRunClient) SwarmLeave(ctx context.Context, force bool) error {
  768. if d.SwarmLeaveFn == nil {
  769. return ErrNotImplemented
  770. }
  771. return d.SwarmLeaveFn(ctx, force)
  772. }
  773. func (d *DryRunClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
  774. if d.SwarmInspectFn == nil {
  775. return swarm.Swarm{}, ErrNotImplemented
  776. }
  777. return d.SwarmInspectFn(ctx)
  778. }
  779. func (d *DryRunClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarmSpec swarm.Spec, flags swarm.UpdateFlags) error {
  780. if d.SwarmUpdateFn == nil {
  781. return ErrNotImplemented
  782. }
  783. return d.SwarmUpdateFn(ctx, version, swarmSpec, flags)
  784. }
  785. func (d *DryRunClient) SecretList(ctx context.Context, options moby.SecretListOptions) ([]swarm.Secret, error) {
  786. if d.SecretListFn == nil {
  787. return nil, ErrNotImplemented
  788. }
  789. return d.SecretListFn(ctx, options)
  790. }
  791. func (d *DryRunClient) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (moby.SecretCreateResponse, error) {
  792. if d.SecretCreateFn == nil {
  793. return moby.SecretCreateResponse{}, ErrNotImplemented
  794. }
  795. return d.SecretCreateFn(ctx, secret)
  796. }
  797. func (d *DryRunClient) SecretRemove(ctx context.Context, id string) error {
  798. if d.SecretRemoveFn == nil {
  799. return ErrNotImplemented
  800. }
  801. return d.SecretRemoveFn(ctx, id)
  802. }
  803. func (d *DryRunClient) SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error) {
  804. if d.SecretInspectWithRawFn == nil {
  805. return swarm.Secret{}, nil, ErrNotImplemented
  806. }
  807. return d.SecretInspectWithRawFn(ctx, name)
  808. }
  809. func (d *DryRunClient) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error {
  810. if d.SecretUpdateFn == nil {
  811. return ErrNotImplemented
  812. }
  813. return d.SecretUpdateFn(ctx, id, version, secret)
  814. }
  815. func (d *DryRunClient) Events(ctx context.Context, options moby.EventsOptions) (<-chan events.Message, <-chan error) {
  816. if d.EventsFn == nil {
  817. errC := make(chan error, 1)
  818. errC <- ErrNotImplemented
  819. return nil, errC
  820. }
  821. return d.EventsFn(ctx, options)
  822. }
  823. func (d *DryRunClient) Info(ctx context.Context) (moby.Info, error) {
  824. if d.InfoFn == nil {
  825. return moby.Info{}, ErrNotImplemented
  826. }
  827. return d.InfoFn(ctx)
  828. }
  829. func (d *DryRunClient) RegistryLogin(ctx context.Context, auth moby.AuthConfig) (registry.AuthenticateOKBody, error) {
  830. if d.RegistryLoginFn == nil {
  831. return registry.AuthenticateOKBody{}, ErrNotImplemented
  832. }
  833. return d.RegistryLoginFn(ctx, auth)
  834. }
  835. func (d *DryRunClient) DiskUsage(ctx context.Context, options moby.DiskUsageOptions) (moby.DiskUsage, error) {
  836. if d.DiskUsageFn == nil {
  837. return moby.DiskUsage{}, ErrNotImplemented
  838. }
  839. return d.DiskUsageFn(ctx, options)
  840. }
  841. func (d *DryRunClient) Ping(ctx context.Context) (moby.Ping, error) {
  842. if d.PingFn == nil {
  843. return moby.Ping{}, ErrNotImplemented
  844. }
  845. return d.PingFn(ctx)
  846. }
  847. func (d *DryRunClient) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) {
  848. if d.VolumeInspectFn == nil {
  849. return volume.Volume{}, ErrNotImplemented
  850. }
  851. return d.VolumeInspectFn(ctx, volumeID)
  852. }
  853. func (d *DryRunClient) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) {
  854. if d.VolumeInspectWithRawFn == nil {
  855. return volume.Volume{}, nil, ErrNotImplemented
  856. }
  857. return d.VolumeInspectWithRawFn(ctx, volumeID)
  858. }
  859. func (d *DryRunClient) VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error) {
  860. if d.VolumeListFn == nil {
  861. return volume.ListResponse{}, ErrNotImplemented
  862. }
  863. return d.VolumeListFn(ctx, filter)
  864. }
  865. func (d *DryRunClient) VolumesPrune(ctx context.Context, pruneFilter filters.Args) (moby.VolumesPruneReport, error) {
  866. if d.VolumesPruneFn == nil {
  867. return moby.VolumesPruneReport{}, ErrNotImplemented
  868. }
  869. return d.VolumesPruneFn(ctx, pruneFilter)
  870. }
  871. func (d *DryRunClient) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error {
  872. if d.VolumeUpdateFn == nil {
  873. return ErrNotImplemented
  874. }
  875. return d.VolumeUpdateFn(ctx, volumeID, version, options)
  876. }
  877. func (d *DryRunClient) ClientVersion() string {
  878. if d.ClientVersionFn == nil {
  879. return "undefined"
  880. }
  881. return d.ClientVersionFn()
  882. }
  883. func (d *DryRunClient) DaemonHost() string {
  884. if d.DaemonHostFn == nil {
  885. return "undefined"
  886. }
  887. return d.DaemonHostFn()
  888. }
  889. func (d *DryRunClient) HTTPClient() *http.Client {
  890. if d.HTTPClientFn == nil {
  891. return nil
  892. }
  893. return d.HTTPClientFn()
  894. }
  895. func (d *DryRunClient) ServerVersion(ctx context.Context) (moby.Version, error) {
  896. if d.ServerVersionFn == nil {
  897. return moby.Version{}, ErrNotImplemented
  898. }
  899. return d.ServerVersionFn(ctx)
  900. }
  901. func (d *DryRunClient) NegotiateAPIVersion(ctx context.Context) {
  902. if d.NegotiateAPIVersionFn == nil {
  903. return
  904. }
  905. d.NegotiateAPIVersionFn(ctx)
  906. }
  907. func (d *DryRunClient) NegotiateAPIVersionPing(ping moby.Ping) {
  908. if d.NegotiateAPIVersionPingFn == nil {
  909. return
  910. }
  911. d.NegotiateAPIVersionPingFn(ping)
  912. }
  913. func (d *DryRunClient) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) {
  914. if d.DialHijackFn == nil {
  915. return nil, ErrNotImplemented
  916. }
  917. return d.DialHijackFn(ctx, url, proto, meta)
  918. }
  919. func (d *DryRunClient) Dialer() func(context.Context) (net.Conn, error) {
  920. if d.DialerFn == nil {
  921. return nil
  922. }
  923. return d.DialerFn()
  924. }
  925. func (d *DryRunClient) Close() error {
  926. if d.CloseFn == nil {
  927. return ErrNotImplemented
  928. }
  929. return d.CloseFn()
  930. }
  931. func (d *DryRunClient) CheckpointCreate(ctx context.Context, container string, options moby.CheckpointCreateOptions) error {
  932. if d.CheckpointCreateFn == nil {
  933. return ErrNotImplemented
  934. }
  935. return d.CheckpointCreateFn(ctx, container, options)
  936. }
  937. func (d *DryRunClient) CheckpointDelete(ctx context.Context, container string, options moby.CheckpointDeleteOptions) error {
  938. if d.CheckpointDeleteFn == nil {
  939. return ErrNotImplemented
  940. }
  941. return d.CheckpointDeleteFn(ctx, container, options)
  942. }
  943. func (d *DryRunClient) CheckpointList(ctx context.Context, container string, options moby.CheckpointListOptions) ([]moby.Checkpoint, error) {
  944. if d.CheckpointListFn == nil {
  945. return nil, ErrNotImplemented
  946. }
  947. return d.CheckpointListFn(ctx, container, options)
  948. }