diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-11-19 13:13:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-19 13:13:51 +0100 |
commit | f3f219a67c3a9297b5e1f0505c583b9de35661c8 (patch) | |
tree | 069f51f6a50d5234e6bc16f2045656aaefb9b313 /pkg/adapter/containers.go | |
parent | 741b90c2b95c533f2ee5669ae1d3b2a93c8129ce (diff) | |
parent | 061bf77588c573668646fb07ded748c9bf375130 (diff) | |
download | podman-f3f219a67c3a9297b5e1f0505c583b9de35661c8.tar.gz podman-f3f219a67c3a9297b5e1f0505c583b9de35661c8.tar.bz2 podman-f3f219a67c3a9297b5e1f0505c583b9de35661c8.zip |
Merge pull request #4523 from vrothberg/systemd-improvements
podman rm/stop --cidfile
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r-- | pkg/adapter/containers.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index 287bd8474..02da9ec8c 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -79,7 +79,17 @@ func (r *LocalRuntime) StopContainers(ctx context.Context, cli *cliconfig.StopVa } logrus.Debugf("Setting maximum stop workers to %d", maxWorkers) - ctrs, err := shortcuts.GetContainersByContext(cli.All, cli.Latest, cli.InputArgs, r.Runtime) + names := cli.InputArgs + for _, cidFile := range cli.CIDFiles { + content, err := ioutil.ReadFile(cidFile) + if err != nil { + return nil, nil, errors.Wrap(err, "error reading CIDFile") + } + id := strings.Split(string(content), "\n")[0] + names = append(names, id) + } + + ctrs, err := shortcuts.GetContainersByContext(cli.All, cli.Latest, names, r.Runtime) if err != nil { return nil, nil, err } @@ -203,7 +213,17 @@ func (r *LocalRuntime) RemoveContainers(ctx context.Context, cli *cliconfig.RmVa return ok, failures, nil } - ctrs, err := shortcuts.GetContainersByContext(cli.All, cli.Latest, cli.InputArgs, r.Runtime) + names := cli.InputArgs + for _, cidFile := range cli.CIDFiles { + content, err := ioutil.ReadFile(cidFile) + if err != nil { + return nil, nil, errors.Wrap(err, "error reading CIDFile") + } + id := strings.Split(string(content), "\n")[0] + names = append(names, id) + } + + ctrs, err := shortcuts.GetContainersByContext(cli.All, cli.Latest, names, r.Runtime) if err != nil { // Failed to get containers. If force is specified, get the containers ID // and evict them |