diff options
author | Sujil02 <sushah@redhat.com> | 2020-03-09 20:07:55 -0400 |
---|---|---|
committer | Sujil02 <sushah@redhat.com> | 2020-03-17 17:46:20 -0400 |
commit | 15326f051d6938e5d3cdcec2f95f86ad3aa5c5fa (patch) | |
tree | 45efba0ddc6a4e5edf821f2d44e847b8d744abe2 /pkg/adapter/pods.go | |
parent | f3a28de3249032e5d7be14114b126c7bddf3d479 (diff) | |
download | podman-15326f051d6938e5d3cdcec2f95f86ad3aa5c5fa.tar.gz podman-15326f051d6938e5d3cdcec2f95f86ad3aa5c5fa.tar.bz2 podman-15326f051d6938e5d3cdcec2f95f86ad3aa5c5fa.zip |
Filter pods through pod list api
Refactored current filter pods flow through the shared pod functions
so filter pod functionalities can be shared between api and cmd.
Signed-off-by: Sujil02 <sushah@redhat.com>
Diffstat (limited to 'pkg/adapter/pods.go')
-rw-r--r-- | pkg/adapter/pods.go | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/pkg/adapter/pods.go b/pkg/adapter/pods.go index dc856cc8d..1417bd2b9 100644 --- a/pkg/adapter/pods.go +++ b/pkg/adapter/pods.go @@ -122,19 +122,31 @@ func (r *LocalRuntime) GetLatestPod() (*Pod, error) { return &pod, err } +// GetPodsWithFilters gets the filtered list of pods based on the filter parameters provided. +func (r *LocalRuntime) GetPodsWithFilters(filters string) ([]*Pod, error) { + pods, err := shared.GetPodsWithFilters(r.Runtime, filters) + if err != nil { + return nil, err + } + return r.podstoAdapterPods(pods) +} + +func (r *LocalRuntime) podstoAdapterPods(pod []*libpod.Pod) ([]*Pod, error) { + var pods []*Pod + for _, i := range pod { + + pods = append(pods, &Pod{i}) + } + return pods, nil +} + // GetAllPods gets all pods and wraps it in an adapter pod func (r *LocalRuntime) GetAllPods() ([]*Pod, error) { - var pods []*Pod allPods, err := r.Runtime.GetAllPods() if err != nil { return nil, err } - for _, p := range allPods { - pod := Pod{} - pod.Pod = p - pods = append(pods, &pod) - } - return pods, nil + return r.podstoAdapterPods(allPods) } // LookupPod gets a pod by name or id and wraps it in an adapter pod |