summaryrefslogtreecommitdiff
path: root/pkg/ps
diff options
context:
space:
mode:
authorflouthoc <flouthoc.git@gmail.com>2021-06-26 18:55:08 +0530
committerflouthoc <flouthoc.git@gmail.com>2021-06-30 09:04:08 +0530
commit2243b6020330ea06abdb594db9c6c8ff429cfc5d (patch)
treed868bbae55668546b5ab579a92a1308208db2e83 /pkg/ps
parent0a0ade3cc00c3779bbf68ddd103d3efd10b5c25b (diff)
downloadpodman-2243b6020330ea06abdb594db9c6c8ff429cfc5d.tar.gz
podman-2243b6020330ea06abdb594db9c6c8ff429cfc5d.tar.bz2
podman-2243b6020330ea06abdb594db9c6c8ff429cfc5d.zip
reset: remove external containers on podman system reset
[NO TESTS NEEDED] Signed-off-by: flouthoc <flouthoc.git@gmail.com>
Diffstat (limited to 'pkg/ps')
-rw-r--r--pkg/ps/ps.go34
1 files changed, 24 insertions, 10 deletions
diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go
index 0b76636de..ef79973d6 100644
--- a/pkg/ps/ps.go
+++ b/pkg/ps/ps.go
@@ -71,18 +71,11 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
}
if options.All && options.External {
- externCons, err := runtime.StorageContainers()
+ listCon, err := GetExternalContainerLists(runtime)
if err != nil {
return nil, err
}
-
- for _, con := range externCons {
- listCon, err := ListStorageContainer(runtime, con, options)
- if err != nil {
- return nil, err
- }
- pss = append(pss, listCon)
- }
+ pss = append(pss, listCon...)
}
// Sort the containers we got
@@ -97,6 +90,27 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
return pss, nil
}
+// GetExternalContainerLists returns list of external containers for e.g created by buildah
+func GetExternalContainerLists(runtime *libpod.Runtime) ([]entities.ListContainer, error) {
+ var (
+ pss = []entities.ListContainer{}
+ )
+
+ externCons, err := runtime.StorageContainers()
+ if err != nil {
+ return nil, err
+ }
+
+ for _, con := range externCons {
+ listCon, err := ListStorageContainer(runtime, con)
+ if err != nil {
+ return nil, err
+ }
+ pss = append(pss, listCon)
+ }
+ return pss, nil
+}
+
// BatchContainerOp is used in ps to reduce performance hits by "batching"
// locks.
func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities.ContainerListOptions) (entities.ListContainer, error) {
@@ -231,7 +245,7 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
return ps, nil
}
-func ListStorageContainer(rt *libpod.Runtime, ctr storage.Container, opts entities.ContainerListOptions) (entities.ListContainer, error) {
+func ListStorageContainer(rt *libpod.Runtime, ctr storage.Container) (entities.ListContainer, error) {
name := "unknown"
if len(ctr.Names) > 0 {
name = ctr.Names[0]