From 25be264ed893edc0f2ec6e65cd062e4e1bdd2e84 Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:21:29 +0100 Subject: [PATCH] support dry-run for exec command Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> --- pkg/api/dryrunclient.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/api/dryrunclient.go b/pkg/api/dryrunclient.go index 18a0f49ca..7fb0531e2 100644 --- a/pkg/api/dryrunclient.go +++ b/pkg/api/dryrunclient.go @@ -155,6 +155,17 @@ func (d *DryRunClient) VolumeRemove(ctx context.Context, volumeID string, force return ErrNotImplemented } +func (d *DryRunClient) ContainerExecCreate(ctx context.Context, container string, config moby.ExecConfig) (moby.IDResponse, error) { + fmt.Printf("%sCreating Exec configuration for container %s with command '%s'\n", DRYRUN_PREFIX, container, strings.Join(config.Cmd, " ")) + config.Cmd = []string{"true"} + return d.apiClient.ContainerExecCreate(ctx, container, config) +} + +func (d *DryRunClient) ContainerExecStart(ctx context.Context, execID string, config moby.ExecStartCheck) error { + fmt.Printf("%sExecuting command in detach mode\n", DRYRUN_PREFIX) + return nil +} + // Functions delegated to original APIClient (not used by Compose or not modifying the Compose stack func (d *DryRunClient) ConfigList(ctx context.Context, options moby.ConfigListOptions) ([]swarm.Config, error) { @@ -189,10 +200,6 @@ func (d *DryRunClient) ContainerExecAttach(ctx context.Context, execID string, c return d.apiClient.ContainerExecAttach(ctx, execID, config) } -func (d *DryRunClient) ContainerExecCreate(ctx context.Context, container string, config moby.ExecConfig) (moby.IDResponse, error) { - return d.apiClient.ContainerExecCreate(ctx, container, config) -} - func (d *DryRunClient) ContainerExecInspect(ctx context.Context, execID string) (moby.ContainerExecInspect, error) { return d.apiClient.ContainerExecInspect(ctx, execID) } @@ -201,10 +208,6 @@ func (d *DryRunClient) ContainerExecResize(ctx context.Context, execID string, o return d.apiClient.ContainerExecResize(ctx, execID, options) } -func (d *DryRunClient) ContainerExecStart(ctx context.Context, execID string, config moby.ExecStartCheck) error { - return d.apiClient.ContainerExecStart(ctx, execID, config) -} - func (d *DryRunClient) ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) { return d.apiClient.ContainerExport(ctx, container) }