(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)
| 36 | } |
| 37 | |
| 38 | func killCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { |
| 39 | opts := killOptions{ |
| 40 | ProjectOptions: p, |
| 41 | } |
| 42 | cmd := &cobra.Command{ |
| 43 | Use: "kill [OPTIONS] [SERVICE...]", |
| 44 | Short: "Force stop service containers", |
| 45 | RunE: Adapt(func(ctx context.Context, args []string) error { |
| 46 | return runKill(ctx, dockerCli, backendOptions, opts, args) |
| 47 | }), |
| 48 | ValidArgsFunction: completeServiceNames(dockerCli, p), |
| 49 | } |
| 50 | |
| 51 | flags := cmd.Flags() |
| 52 | removeOrphans := utils.StringToBool(os.Getenv(ComposeRemoveOrphans)) |
| 53 | flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file") |
| 54 | flags.StringVarP(&opts.signal, "signal", "s", "SIGKILL", "SIGNAL to send to the container") |
| 55 | |
| 56 | return cmd |
| 57 | } |
| 58 | |
| 59 | func runKill(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts killOptions, services []string) error { |
| 60 | project, name, err := opts.projectOrName(ctx, dockerCli, services...) |
no test coverage detected