Skip to content

Commit eb1c798

Browse files
gloursndeloof
authored andcommitted
support dry-run for rm command
Signed-off-by: Guillaume Lours <[email protected]>
1 parent 78b9404 commit eb1c798

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

cmd/compose/remove.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ func runRemove(ctx context.Context, backend api.Service, opts removeOptions, ser
7979
Force: opts.force,
8080
Volumes: opts.volumes,
8181
Project: project,
82+
Stop: opts.stop,
8283
})
8384
}

pkg/api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ type KillOptions struct {
229229
type RemoveOptions struct {
230230
// Project is the compose project used to define this app. Might be nil if user ran command just with project name
231231
Project *types.Project
232-
// DryRun just list removable resources
233-
DryRun bool
232+
// Stop option passed in the command line
233+
Stop bool
234234
// Volumes remove anonymous volumes
235235
Volumes bool
236236
// Force don't ask to confirm removal

pkg/api/dryrunclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (d *DryRunClient) ContainerPause(ctx context.Context, container string) err
7777
}
7878

7979
func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options moby.ContainerRemoveOptions) error {
80-
return ErrNotImplemented
80+
return nil
8181
}
8282

8383
func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error {

pkg/compose/remove.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (s *composeService) Remove(ctx context.Context, projectName string, options
4545
}
4646

4747
stoppedContainers := containers.filter(func(c moby.Container) bool {
48-
return c.State != ContainerRunning
48+
return c.State != ContainerRunning || (options.Stop && s.dryRun)
4949
})
5050

5151
var names []string

0 commit comments

Comments
 (0)