From c81e29525b0ea84107147d92283c2b88909d1f12 Mon Sep 17 00:00:00 2001 From: baude Date: Wed, 23 Dec 2020 11:02:52 -0600 Subject: add --cidfile to container kill Add the ability to read container ids from one or more files for the kill command. Fixes: #8443 Signed-off-by: baude --- pkg/domain/infra/tunnel/containers.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkg/domain/infra/tunnel') diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go index 7704de210..0db985dff 100644 --- a/pkg/domain/infra/tunnel/containers.go +++ b/pkg/domain/infra/tunnel/containers.go @@ -125,6 +125,14 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin } func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []string, opts entities.KillOptions) ([]*entities.KillReport, error) { + for _, cidFile := range opts.CIDFiles { + content, err := ioutil.ReadFile(cidFile) + if err != nil { + return nil, errors.Wrap(err, "error reading CIDFile") + } + id := strings.Split(string(content), "\n")[0] + namesOrIds = append(namesOrIds, id) + } ctrs, err := getContainersByContext(ic.ClientCtx, opts.All, false, namesOrIds) if err != nil { return nil, err -- cgit v1.2.3-54-g00ecf