Преглед изворни кода

Expose `—remove-orphans` in compose down command

Signed-off-by: Guillaume Tardif <[email protected]>
Guillaume Tardif пре 4 година
родитељ
комит
4b20d77a86
1 измењених фајлова са 5 додато и 1 уклоњено
  1. 5 1
      cli/cmd/compose/down.go

+ 5 - 1
cli/cmd/compose/down.go

@@ -31,6 +31,7 @@ import (
 
 type downOptions struct {
 	*projectOptions
+	removeOrphans bool
 }
 
 func downCommand(p *projectOptions) *cobra.Command {
@@ -44,6 +45,9 @@ func downCommand(p *projectOptions) *cobra.Command {
 			return runDown(cmd.Context(), opts)
 		},
 	}
+	flags := downCmd.Flags()
+	flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
+
 	return downCmd
 }
 
@@ -66,7 +70,7 @@ func runDown(ctx context.Context, opts downOptions) error {
 		}
 
 		return name, c.ComposeService().Down(ctx, name, compose.DownOptions{
-			RemoveOrphans: false,
+			RemoveOrphans: opts.removeOrphans,
 			Project:       project,
 		})
 	})