Skip to content

Commit 3fac506

Browse files
committed
identify functions which need to be ovorridden for dry run feature
Signed-off-by: Guillaume Lours <[email protected]>
1 parent eb59b0e commit 3fac506

File tree

1 file changed

+93
-152
lines changed

1 file changed

+93
-152
lines changed

pkg/api/dryrunclient.go

Lines changed: 93 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,99 @@ func (d *DryRunClient) WithAPIClient(apiClient client.APIClient) {
290290
d.CheckpointListFn = apiClient.CheckpointList
291291
}
292292

293+
// All methods and functions which need to be overridden for dry run.
294+
295+
func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options moby.ContainerAttachOptions) (moby.HijackedResponse, error) {
296+
return moby.HijackedResponse{}, ErrNotImplemented
297+
}
298+
299+
func (d *DryRunClient) ContainerCreate(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig,
300+
networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (containerType.CreateResponse, error) {
301+
return containerType.CreateResponse{}, ErrNotImplemented
302+
}
303+
304+
func (d *DryRunClient) ContainerKill(ctx context.Context, container, signal string) error {
305+
return ErrNotImplemented
306+
}
307+
308+
func (d *DryRunClient) ContainerPause(ctx context.Context, container string) error {
309+
return ErrNotImplemented
310+
}
311+
312+
func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options moby.ContainerRemoveOptions) error {
313+
return ErrNotImplemented
314+
}
315+
316+
func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error {
317+
return ErrNotImplemented
318+
}
319+
320+
func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, options containerType.StopOptions) error {
321+
return ErrNotImplemented
322+
}
323+
324+
func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options moby.ContainerStartOptions) error {
325+
return ErrNotImplemented
326+
}
327+
328+
func (d *DryRunClient) ContainerStop(ctx context.Context, container string, options containerType.StopOptions) error {
329+
return ErrNotImplemented
330+
}
331+
332+
func (d *DryRunClient) ContainerUnpause(ctx context.Context, container string) error {
333+
return ErrNotImplemented
334+
}
335+
336+
func (d *DryRunClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, moby.ContainerPathStat, error) {
337+
return nil, moby.ContainerPathStat{}, ErrNotImplemented
338+
}
339+
340+
func (d *DryRunClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options moby.CopyToContainerOptions) error {
341+
return ErrNotImplemented
342+
}
343+
344+
func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options moby.ImageBuildOptions) (moby.ImageBuildResponse, error) {
345+
return moby.ImageBuildResponse{}, ErrNotImplemented
346+
}
347+
348+
func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options moby.ImagePullOptions) (io.ReadCloser, error) {
349+
return nil, ErrNotImplemented
350+
}
351+
352+
func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options moby.ImagePushOptions) (io.ReadCloser, error) {
353+
return nil, ErrNotImplemented
354+
}
355+
356+
func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options moby.ImageRemoveOptions) ([]moby.ImageDeleteResponseItem, error) {
357+
return nil, ErrNotImplemented
358+
}
359+
360+
func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, container string, config *network.EndpointSettings) error {
361+
return ErrNotImplemented
362+
}
363+
364+
func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options moby.NetworkCreate) (moby.NetworkCreateResponse, error) {
365+
return moby.NetworkCreateResponse{}, ErrNotImplemented
366+
}
367+
368+
func (d *DryRunClient) NetworkDisconnect(ctx context.Context, networkName, container string, force bool) error {
369+
return ErrNotImplemented
370+
}
371+
372+
func (d *DryRunClient) NetworkRemove(ctx context.Context, networkName string) error {
373+
return ErrNotImplemented
374+
}
375+
376+
func (d *DryRunClient) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
377+
return volume.Volume{}, ErrNotImplemented
378+
}
379+
380+
func (d *DryRunClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
381+
return ErrNotImplemented
382+
}
383+
384+
// Functions delegated to original APIClient (not used by Compose or not modifying the Compose stack
385+
293386
func (d *DryRunClient) ConfigList(ctx context.Context, options moby.ConfigListOptions) ([]swarm.Config, error) {
294387
if d.ConfigListFn == nil {
295388
return nil, ErrNotImplemented
@@ -325,28 +418,13 @@ func (d *DryRunClient) ConfigUpdate(ctx context.Context, id string, version swar
325418
return d.ConfigUpdateFn(ctx, id, version, config)
326419
}
327420

328-
func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options moby.ContainerAttachOptions) (moby.HijackedResponse, error) {
329-
if d.ContainerAttachFn == nil {
330-
return moby.HijackedResponse{}, ErrNotImplemented
331-
}
332-
return d.ContainerAttachFn(ctx, container, options)
333-
}
334-
335421
func (d *DryRunClient) ContainerCommit(ctx context.Context, container string, options moby.ContainerCommitOptions) (moby.IDResponse, error) {
336422
if d.ContainerCommitFn == nil {
337423
return moby.IDResponse{}, ErrNotImplemented
338424
}
339425
return d.ContainerCommitFn(ctx, container, options)
340426
}
341427

342-
func (d *DryRunClient) ContainerCreate(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig,
343-
networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (containerType.CreateResponse, error) {
344-
if d.ContainerCreateFn == nil {
345-
return containerType.CreateResponse{}, ErrNotImplemented
346-
}
347-
return d.ContainerCreateFn(ctx, config, hostConfig, networkingConfig, platform, containerName)
348-
}
349-
350428
func (d *DryRunClient) ContainerDiff(ctx context.Context, container string) ([]containerType.ContainerChangeResponseItem, error) {
351429
if d.ContainerDiffFn == nil {
352430
return nil, ErrNotImplemented
@@ -410,13 +488,6 @@ func (d *DryRunClient) ContainerInspectWithRaw(ctx context.Context, container st
410488
return d.ContainerInspectWithRawFn(ctx, container, getSize)
411489
}
412490

413-
func (d *DryRunClient) ContainerKill(ctx context.Context, container, signal string) error {
414-
if d.ContainerKillFn == nil {
415-
return ErrNotImplemented
416-
}
417-
return d.ContainerKillFn(ctx, container, signal)
418-
}
419-
420491
func (d *DryRunClient) ContainerList(ctx context.Context, options moby.ContainerListOptions) ([]moby.Container, error) {
421492
if d.ContainerListFn == nil {
422493
return nil, ErrNotImplemented
@@ -431,41 +502,13 @@ func (d *DryRunClient) ContainerLogs(ctx context.Context, container string, opti
431502
return d.ContainerLogsFn(ctx, container, options)
432503
}
433504

434-
func (d *DryRunClient) ContainerPause(ctx context.Context, container string) error {
435-
if d.ContainerPauseFn == nil {
436-
return ErrNotImplemented
437-
}
438-
return d.ContainerPauseFn(ctx, container)
439-
}
440-
441-
func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options moby.ContainerRemoveOptions) error {
442-
if d.ContainerRemoveFn == nil {
443-
return ErrNotImplemented
444-
}
445-
return d.ContainerRemoveFn(ctx, container, options)
446-
}
447-
448-
func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error {
449-
if d.ContainerRenameFn == nil {
450-
return ErrNotImplemented
451-
}
452-
return d.ContainerRenameFn(ctx, container, newContainerName)
453-
}
454-
455505
func (d *DryRunClient) ContainerResize(ctx context.Context, container string, options moby.ResizeOptions) error {
456506
if d.ContainerResizeFn == nil {
457507
return ErrNotImplemented
458508
}
459509
return d.ContainerResizeFn(ctx, container, options)
460510
}
461511

462-
func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, options containerType.StopOptions) error {
463-
if d.ContainerRestartFn == nil {
464-
return ErrNotImplemented
465-
}
466-
return d.ContainerRestartFn(ctx, container, options)
467-
}
468-
469512
func (d *DryRunClient) ContainerStatPath(ctx context.Context, container, path string) (moby.ContainerPathStat, error) {
470513
if d.ContainerStatPathFn == nil {
471514
return moby.ContainerPathStat{}, ErrNotImplemented
@@ -487,34 +530,13 @@ func (d *DryRunClient) ContainerStatsOneShot(ctx context.Context, container stri
487530
return d.ContainerStatsOneShotFn(ctx, container)
488531
}
489532

490-
func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options moby.ContainerStartOptions) error {
491-
if d.ContainerStartFn == nil {
492-
return ErrNotImplemented
493-
}
494-
return d.ContainerStartFn(ctx, container, options)
495-
}
496-
497-
func (d *DryRunClient) ContainerStop(ctx context.Context, container string, options containerType.StopOptions) error {
498-
if d.ContainerStopFn == nil {
499-
return ErrNotImplemented
500-
}
501-
return d.ContainerStopFn(ctx, container, options)
502-
}
503-
504533
func (d *DryRunClient) ContainerTop(ctx context.Context, container string, arguments []string) (containerType.ContainerTopOKBody, error) {
505534
if d.ContainerTopFn == nil {
506535
return containerType.ContainerTopOKBody{}, ErrNotImplemented
507536
}
508537
return d.ContainerTopFn(ctx, container, arguments)
509538
}
510539

511-
func (d *DryRunClient) ContainerUnpause(ctx context.Context, container string) error {
512-
if d.ContainerUnpauseFn == nil {
513-
return ErrNotImplemented
514-
}
515-
return d.ContainerUnpauseFn(ctx, container)
516-
}
517-
518540
func (d *DryRunClient) ContainerUpdate(ctx context.Context, container string, updateConfig containerType.UpdateConfig) (containerType.ContainerUpdateOKBody, error) {
519541
if d.ContainerUpdateFn == nil {
520542
return containerType.ContainerUpdateOKBody{}, ErrNotImplemented
@@ -531,20 +553,6 @@ func (d *DryRunClient) ContainerWait(ctx context.Context, container string, cond
531553
return d.ContainerWaitFn(ctx, container, condition)
532554
}
533555

534-
func (d *DryRunClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, moby.ContainerPathStat, error) {
535-
if d.CopyFromContainerFn == nil {
536-
return nil, moby.ContainerPathStat{}, ErrNotImplemented
537-
}
538-
return d.CopyFromContainerFn(ctx, container, srcPath)
539-
}
540-
541-
func (d *DryRunClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options moby.CopyToContainerOptions) error {
542-
if d.CopyToContainerFn == nil {
543-
return ErrNotImplemented
544-
}
545-
return d.CopyToContainerFn(ctx, container, path, content, options)
546-
}
547-
548556
func (d *DryRunClient) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (moby.ContainersPruneReport, error) {
549557
if d.ContainersPruneFn == nil {
550558
return moby.ContainersPruneReport{}, ErrNotImplemented
@@ -559,13 +567,6 @@ func (d *DryRunClient) DistributionInspect(ctx context.Context, imageName, encod
559567
return d.DistributionInspectFn(ctx, imageName, encodedRegistryAuth)
560568
}
561569

562-
func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options moby.ImageBuildOptions) (moby.ImageBuildResponse, error) {
563-
if d.ImageBuildFn == nil {
564-
return moby.ImageBuildResponse{}, ErrNotImplemented
565-
}
566-
return d.ImageBuildFn(ctx, reader, options)
567-
}
568-
569570
func (d *DryRunClient) BuildCachePrune(ctx context.Context, opts moby.BuildCachePruneOptions) (*moby.BuildCachePruneReport, error) {
570571
if d.BuildCachePruneFn == nil {
571572
return nil, ErrNotImplemented
@@ -622,27 +623,6 @@ func (d *DryRunClient) ImageLoad(ctx context.Context, input io.Reader, quiet boo
622623
return d.ImageLoadFn(ctx, input, quiet)
623624
}
624625

625-
func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options moby.ImagePullOptions) (io.ReadCloser, error) {
626-
if d.ImagePullFn == nil {
627-
return nil, ErrNotImplemented
628-
}
629-
return d.ImagePullFn(ctx, ref, options)
630-
}
631-
632-
func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options moby.ImagePushOptions) (io.ReadCloser, error) {
633-
if d.ImagePushFn == nil {
634-
return nil, ErrNotImplemented
635-
}
636-
return d.ImagePushFn(ctx, ref, options)
637-
}
638-
639-
func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options moby.ImageRemoveOptions) ([]moby.ImageDeleteResponseItem, error) {
640-
if d.ImageRemoveFn == nil {
641-
return nil, ErrNotImplemented
642-
}
643-
return d.ImageRemoveFn(ctx, imageName, options)
644-
}
645-
646626
func (d *DryRunClient) ImageSearch(ctx context.Context, term string, options moby.ImageSearchOptions) ([]registry.SearchResult, error) {
647627
if d.ImageSearchFn == nil {
648628
return nil, ErrNotImplemented
@@ -699,27 +679,6 @@ func (d *DryRunClient) NodeUpdate(ctx context.Context, nodeID string, version sw
699679
return d.NodeUpdateFn(ctx, nodeID, version, node)
700680
}
701681

702-
func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, container string, config *network.EndpointSettings) error {
703-
if d.NetworkConnectFn == nil {
704-
return ErrNotImplemented
705-
}
706-
return d.NetworkConnectFn(ctx, networkName, container, config)
707-
}
708-
709-
func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options moby.NetworkCreate) (moby.NetworkCreateResponse, error) {
710-
if d.NetworkCreateFn == nil {
711-
return moby.NetworkCreateResponse{}, ErrNotImplemented
712-
}
713-
return d.NetworkCreateFn(ctx, name, options)
714-
}
715-
716-
func (d *DryRunClient) NetworkDisconnect(ctx context.Context, networkName, container string, force bool) error {
717-
if d.NetworkDisconnectFn == nil {
718-
return ErrNotImplemented
719-
}
720-
return d.NetworkDisconnectFn(ctx, networkName, container, force)
721-
}
722-
723682
func (d *DryRunClient) NetworkInspect(ctx context.Context, networkName string, options moby.NetworkInspectOptions) (moby.NetworkResource, error) {
724683
if d.NetworkInspectFn == nil {
725684
return moby.NetworkResource{}, ErrNotImplemented
@@ -741,10 +700,6 @@ func (d *DryRunClient) NetworkList(ctx context.Context, options moby.NetworkList
741700
return d.NetworkListFn(ctx, options)
742701
}
743702

744-
func (d *DryRunClient) NetworkRemove(ctx context.Context, networkName string) error {
745-
return d.NetworkRemoveFn(ctx, networkName)
746-
}
747-
748703
func (d *DryRunClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (moby.NetworksPruneReport, error) {
749704
if d.NetworksPruneFn == nil {
750705
return moby.NetworksPruneReport{}, ErrNotImplemented
@@ -1006,13 +961,6 @@ func (d *DryRunClient) Ping(ctx context.Context) (moby.Ping, error) {
1006961
return d.PingFn(ctx)
1007962
}
1008963

1009-
func (d *DryRunClient) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
1010-
if d.VolumeCreateFn == nil {
1011-
return volume.Volume{}, ErrNotImplemented
1012-
}
1013-
return d.VolumeCreateFn(ctx, options)
1014-
}
1015-
1016964
func (d *DryRunClient) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) {
1017965
if d.VolumeInspectFn == nil {
1018966
return volume.Volume{}, ErrNotImplemented
@@ -1034,13 +982,6 @@ func (d *DryRunClient) VolumeList(ctx context.Context, filter filters.Args) (vol
1034982
return d.VolumeListFn(ctx, filter)
1035983
}
1036984

1037-
func (d *DryRunClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
1038-
if d.VolumeRemoveFn == nil {
1039-
return ErrNotImplemented
1040-
}
1041-
return d.VolumeRemoveFn(ctx, volumeID, force)
1042-
}
1043-
1044985
func (d *DryRunClient) VolumesPrune(ctx context.Context, pruneFilter filters.Args) (moby.VolumesPruneReport, error) {
1045986
if d.VolumesPruneFn == nil {
1046987
return moby.VolumesPruneReport{}, ErrNotImplemented

0 commit comments

Comments
 (0)