diff options
author | Brent Baude <bbaude@redhat.com> | 2020-03-19 16:50:15 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-03-20 12:54:45 -0500 |
commit | 87293028e61d0c88c258ed9f4a82c4be7f0bc896 (patch) | |
tree | cd3c6f35eed940e41afed71e7f60f7a8abac1612 /pkg/domain/infra/abi/containers.go | |
parent | ccc30c606e843d5c98e2c62a3b393a61e60976b2 (diff) | |
download | podman-87293028e61d0c88c258ed9f4a82c4be7f0bc896.tar.gz podman-87293028e61d0c88c258ed9f4a82c4be7f0bc896.tar.bz2 podman-87293028e61d0c88c258ed9f4a82c4be7f0bc896.zip |
podmanv2 container exists|wait
enable container exists and wait for podmanv2
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi/containers.go')
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go new file mode 100644 index 000000000..618e9a111 --- /dev/null +++ b/pkg/domain/infra/abi/containers.go @@ -0,0 +1,71 @@ +// +build ABISupport + +package abi + +import ( + "context" + + "github.com/containers/libpod/libpod/define" + "github.com/containers/libpod/pkg/adapter/shortcuts" + "github.com/containers/libpod/pkg/domain/entities" + "github.com/pkg/errors" +) + +// TODO: Should return *entities.ContainerExistsReport, error +func (ic *ContainerEngine) ContainerExists(ctx context.Context, nameOrId string) (bool, error) { + _, err := ic.Libpod.LookupContainer(nameOrId) + if err != nil && errors.Cause(err) != define.ErrNoSuchCtr { + return false, err + } + return err == nil, nil +} + +func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []string, options entities.WaitOptions) ([]entities.WaitReport, error) { + var ( + responses []entities.WaitReport + ) + condition, err := define.StringToContainerStatus(options.Condition) + if err != nil { + return nil, err + } + + ctrs, err := shortcuts.GetContainersByContext(false, options.Latest, namesOrIds, ic.Libpod) + if err != nil { + return nil, err + } + for _, c := range ctrs { + response := entities.WaitReport{Id: c.ID()} + exitCode, err := c.WaitForConditionWithInterval(options.Interval, condition) + if err != nil { + response.Error = err + } else { + response.ExitCode = exitCode + } + responses = append(responses, response) + } + return responses, nil +} + +func (ic *ContainerEngine) ContainerDelete(ctx context.Context, opts entities.ContainerDeleteOptions) (*entities.ContainerDeleteReport, error) { + panic("implement me") +} + +func (ic *ContainerEngine) ContainerPrune(ctx context.Context) (*entities.ContainerPruneReport, error) { + panic("implement me") +} + +func (ic *ContainerEngine) PodDelete(ctx context.Context, opts entities.PodPruneOptions) (*entities.PodDeleteReport, error) { + panic("implement me") +} + +func (ic *ContainerEngine) PodPrune(ctx context.Context) (*entities.PodPruneReport, error) { + panic("implement me") +} + +func (ic *ContainerEngine) VolumeDelete(ctx context.Context, opts entities.VolumeDeleteOptions) (*entities.VolumeDeleteReport, error) { + panic("implement me") +} + +func (ic *ContainerEngine) VolumePrune(ctx context.Context) (*entities.VolumePruneReport, error) { + panic("implement me") +} |