mirror of https://github.com/docker/cli.git
Support parallel kill
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
This commit is contained in:
parent
b7722cd80a
commit
f612b93d33
|
@ -39,8 +39,11 @@ func NewKillCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
func runKill(dockerCli *command.DockerCli, opts *killOptions) error {
|
func runKill(dockerCli *command.DockerCli, opts *killOptions) error {
|
||||||
var errs []string
|
var errs []string
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, container string) error {
|
||||||
|
return dockerCli.Client().ContainerKill(ctx, container, opts.signal)
|
||||||
|
})
|
||||||
for _, name := range opts.containers {
|
for _, name := range opts.containers {
|
||||||
if err := dockerCli.Client().ContainerKill(ctx, name, opts.signal); err != nil {
|
if err := <-errChan; err != nil {
|
||||||
errs = append(errs, err.Error())
|
errs = append(errs, err.Error())
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(dockerCli.Out(), "%s\n", name)
|
fmt.Fprintf(dockerCli.Out(), "%s\n", name)
|
||||||
|
|
Loading…
Reference in New Issue