diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-04-19 05:42:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-19 05:42:24 -0700 |
commit | 9f92b21d69719fb54e6f4712d11ebeeebd5a8714 (patch) | |
tree | 409dfe0466aa8024a6295e40901a17b8b62b8691 /pkg/adapter/runtime.go | |
parent | e4947e5fd699f584cb815a4f4fd92f22b62f2c8a (diff) | |
parent | 69962682e990ddb9437291b98bd335e74c090fc8 (diff) | |
download | podman-9f92b21d69719fb54e6f4712d11ebeeebd5a8714.tar.gz podman-9f92b21d69719fb54e6f4712d11ebeeebd5a8714.tar.bz2 podman-9f92b21d69719fb54e6f4712d11ebeeebd5a8714.zip |
Merge pull request #2970 from jwhonce/wip/remote_pod_prune
Refactor of 'podman prune' to better support remote
Diffstat (limited to 'pkg/adapter/runtime.go')
-rw-r--r-- | pkg/adapter/runtime.go | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/pkg/adapter/runtime.go b/pkg/adapter/runtime.go index 6ed9cee77..753f7c944 100644 --- a/pkg/adapter/runtime.go +++ b/pkg/adapter/runtime.go @@ -7,7 +7,6 @@ import ( "context" "io" "io/ioutil" - "k8s.io/api/core/v1" "os" "text/template" @@ -25,6 +24,7 @@ import ( "github.com/containers/libpod/pkg/rootless" "github.com/containers/storage/pkg/archive" "github.com/pkg/errors" + "k8s.io/api/core/v1" ) // LocalRuntime describes a typical libpod runtime @@ -43,6 +43,11 @@ type Container struct { *libpod.Container } +// Pod encapsulates the libpod.Pod structure, helps with remote vs. local +type Pod struct { + *libpod.Pod +} + // Volume ... type Volume struct { *libpod.Volume @@ -371,8 +376,7 @@ func (r *LocalRuntime) GenerateKube(c *cliconfig.GenerateKubeValues) (*v1.Pod, * } // GetPodsByStatus returns a slice of pods filtered by a libpod status -func (r *LocalRuntime) GetPodsByStatus(statuses []string) ([]*Pod, error) { - var adapterPods []*Pod +func (r *LocalRuntime) GetPodsByStatus(statuses []string) ([]*libpod.Pod, error) { filterFunc := func(p *libpod.Pod) bool { state, _ := shared.GetPodStatus(p) @@ -383,25 +387,11 @@ func (r *LocalRuntime) GetPodsByStatus(statuses []string) ([]*Pod, error) { } return false } + pods, err := r.Runtime.Pods(filterFunc) if err != nil { return nil, err } - for _, p := range pods { - adapterPod := Pod{ - p, - } - adapterPods = append(adapterPods, &adapterPod) - } - return adapterPods, nil -} -// RemovePod removes a pod -// If removeCtrs is specified, containers will be removed -// Otherwise, a pod that is not empty will return an error and not be removed -// If force is specified with removeCtrs, all containers will be stopped before -// being removed -// Otherwise, the pod will not be removed if any containers are running -func (r *LocalRuntime) RemovePod(ctx context.Context, p *Pod, removeCtrs, force bool) error { - return r.Runtime.RemovePod(ctx, p.Pod, removeCtrs, force) + return pods, nil } |