diff options
author | Brent Baude <bbaude@redhat.com> | 2020-03-20 14:00:05 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-03-20 14:33:33 -0500 |
commit | c81e065149da73ae904aa19ee46a23d1ab8ce55c (patch) | |
tree | 52a8692894690a8f09e025f90d6d2b5045259e4f /pkg/domain/infra/tunnel/helpers.go | |
parent | 4a00409bf8c88174cbdbc12760d3f8ddce9621de (diff) | |
download | podman-c81e065149da73ae904aa19ee46a23d1ab8ce55c.tar.gz podman-c81e065149da73ae904aa19ee46a23d1ab8ce55c.tar.bz2 podman-c81e065149da73ae904aa19ee46a23d1ab8ce55c.zip |
podmanv2 enable remote wait
enable remote container wait with condition
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 | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/pkg/domain/infra/tunnel/helpers.go b/pkg/domain/infra/tunnel/helpers.go new file mode 100644 index 000000000..d5a3224c2 --- /dev/null +++ b/pkg/domain/infra/tunnel/helpers.go @@ -0,0 +1,41 @@ +package tunnel + +import ( + "context" + + "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/util" + "github.com/pkg/errors" +) + +func getContainersByContext(contextWithConnection context.Context, all bool, namesOrIds []string) ([]libpod.ListContainer, error) { + var ( + cons []libpod.ListContainer + ) + if all && len(namesOrIds) > 0 { + return nil, errors.New("cannot lookup containers and all") + } + c, err := containers.List(contextWithConnection, nil, &bindings.PTrue, nil, nil, nil, &bindings.PTrue) + if err != nil { + return nil, err + } + if all { + return c, err + } + for _, id := range namesOrIds { + var found bool + for _, con := range c { + if id == con.ID || util.StringInSlice(id, con.Names) { + cons = append(cons, con) + found = true + break + } + } + if !found { + return nil, errors.Errorf("unable to find container %q", id) + } + } + return cons, nil +} |