diff options
author | Brent Baude <bbaude@redhat.com> | 2020-03-22 13:36:35 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-03-26 14:14:05 -0500 |
commit | c5ce210f7d091a4fa6d69abb9b4068c811a26129 (patch) | |
tree | 6fc011ab6c7114ec215e0443e935396150c3dac1 /pkg/domain/infra/tunnel/helpers.go | |
parent | 913426c70c37a87d425085f60af397f7b38bd65d (diff) | |
download | podman-c5ce210f7d091a4fa6d69abb9b4068c811a26129.tar.gz podman-c5ce210f7d091a4fa6d69abb9b4068c811a26129.tar.bz2 podman-c5ce210f7d091a4fa6d69abb9b4068c811a26129.zip |
podmanv2 pod subcommands
add pod kill, pause, restart, rm, start, stop, and unpause
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/domain/infra/tunnel/helpers.go')
-rw-r--r-- | pkg/domain/infra/tunnel/helpers.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pkg/domain/infra/tunnel/helpers.go b/pkg/domain/infra/tunnel/helpers.go index 11fca5278..f9183c955 100644 --- a/pkg/domain/infra/tunnel/helpers.go +++ b/pkg/domain/infra/tunnel/helpers.go @@ -4,9 +4,12 @@ import ( "context" "strings" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/pkg/api/handlers/libpod" "github.com/containers/libpod/pkg/bindings" "github.com/containers/libpod/pkg/bindings/containers" + "github.com/containers/libpod/pkg/bindings/pods" + "github.com/containers/libpod/pkg/domain/entities" "github.com/containers/libpod/pkg/util" "github.com/pkg/errors" ) @@ -40,3 +43,34 @@ func getContainersByContext(contextWithConnection context.Context, all bool, nam } return cons, nil } + +func getPodsByContext(contextWithConnection context.Context, all bool, namesOrIds []string) ([]*entities.ListPodsReport, error) { + var ( + sPods []*entities.ListPodsReport + ) + if all && len(namesOrIds) > 0 { + return nil, errors.New("cannot lookup specific pods and all") + } + + fPods, err := pods.List(contextWithConnection, nil) + if err != nil { + return nil, err + } + if all { + return fPods, nil + } + for _, nameOrId := range namesOrIds { + var found bool + for _, f := range fPods { + if f.Name == nameOrId || strings.HasPrefix(f.Id, nameOrId) { + sPods = append(sPods, f) + found = true + break + } + } + if !found { + return nil, errors.Wrapf(define.ErrNoSuchPod, "unable to find pod %q", nameOrId) + } + } + return sPods, nil +} |