aboutsummaryrefslogtreecommitdiff
path: root/pkg/adapter/runtime.go
diff options
context:
space:
mode:
authorPeter Hunt <pehunt@redhat.com>2019-04-15 15:44:32 -0400
committerPeter Hunt <pehunt@redhat.com>2019-04-16 11:23:18 -0400
commit4319552cf89e72925a80c63f427e5ef0a6376046 (patch)
tree5a0e38e63a41fdafe7f5d08daf496a0d68341aae /pkg/adapter/runtime.go
parent0b34b4a59cf090a47a2a13cc4814954c497b3d49 (diff)
downloadpodman-4319552cf89e72925a80c63f427e5ef0a6376046.tar.gz
podman-4319552cf89e72925a80c63f427e5ef0a6376046.tar.bz2
podman-4319552cf89e72925a80c63f427e5ef0a6376046.zip
Added remote pod prune
Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'pkg/adapter/runtime.go')
-rw-r--r--pkg/adapter/runtime.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/pkg/adapter/runtime.go b/pkg/adapter/runtime.go
index b5ec9f7a9..6ed9cee77 100644
--- a/pkg/adapter/runtime.go
+++ b/pkg/adapter/runtime.go
@@ -369,3 +369,39 @@ func (r *LocalRuntime) Diff(c *cliconfig.DiffValues, to string) ([]archive.Chang
func (r *LocalRuntime) GenerateKube(c *cliconfig.GenerateKubeValues) (*v1.Pod, *v1.Service, error) {
return shared.GenerateKube(c.InputArgs[0], c.Service, r.Runtime)
}
+
+// GetPodsByStatus returns a slice of pods filtered by a libpod status
+func (r *LocalRuntime) GetPodsByStatus(statuses []string) ([]*Pod, error) {
+ var adapterPods []*Pod
+
+ filterFunc := func(p *libpod.Pod) bool {
+ state, _ := shared.GetPodStatus(p)
+ for _, status := range statuses {
+ if state == status {
+ return true
+ }
+ }
+ 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)
+}