support dry-run for rm command

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2023-02-08 22:40:07 +01:00 committed by Nicolas De loof
parent 78b9404767
commit eb1c798912
4 changed files with 5 additions and 4 deletions

View File

@ -79,5 +79,6 @@ func runRemove(ctx context.Context, backend api.Service, opts removeOptions, ser
Force: opts.force, Force: opts.force,
Volumes: opts.volumes, Volumes: opts.volumes,
Project: project, Project: project,
Stop: opts.stop,
}) })
} }

View File

@ -229,8 +229,8 @@ type KillOptions struct {
type RemoveOptions struct { type RemoveOptions struct {
// Project is the compose project used to define this app. Might be nil if user ran command just with project name // Project is the compose project used to define this app. Might be nil if user ran command just with project name
Project *types.Project Project *types.Project
// DryRun just list removable resources // Stop option passed in the command line
DryRun bool Stop bool
// Volumes remove anonymous volumes // Volumes remove anonymous volumes
Volumes bool Volumes bool
// Force don't ask to confirm removal // Force don't ask to confirm removal

View File

@ -77,7 +77,7 @@ func (d *DryRunClient) ContainerPause(ctx context.Context, container string) err
} }
func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options moby.ContainerRemoveOptions) error { func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options moby.ContainerRemoveOptions) error {
return ErrNotImplemented return nil
} }
func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error { func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error {

View File

@ -45,7 +45,7 @@ func (s *composeService) Remove(ctx context.Context, projectName string, options
} }
stoppedContainers := containers.filter(func(c moby.Container) bool { stoppedContainers := containers.filter(func(c moby.Container) bool {
return c.State != ContainerRunning return c.State != ContainerRunning || (options.Stop && s.dryRun)
}) })
var names []string var names []string