Bläddra i källkod

support dry-run for rm command

Signed-off-by: Guillaume Lours <[email protected]>
Guillaume Lours 2 år sedan
förälder
incheckning
eb1c798912
4 ändrade filer med 5 tillägg och 4 borttagningar
  1. 1 0
      cmd/compose/remove.go
  2. 2 2
      pkg/api/api.go
  3. 1 1
      pkg/api/dryrunclient.go
  4. 1 1
      pkg/compose/remove.go

+ 1 - 0
cmd/compose/remove.go

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

+ 2 - 2
pkg/api/api.go

@@ -229,8 +229,8 @@ type KillOptions 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 *types.Project
-	// DryRun just list removable resources
-	DryRun bool
+	// Stop option passed in the command line
+	Stop bool
 	// Volumes remove anonymous volumes
 	Volumes bool
 	// Force don't ask to confirm removal

+ 1 - 1
pkg/api/dryrunclient.go

@@ -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 {
-	return ErrNotImplemented
+	return nil
 }
 
 func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error {

+ 1 - 1
pkg/compose/remove.go

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