diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-03 06:56:42 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-15 09:51:15 -0400 |
commit | 22c8270135620bbbeb988076378173e452ec04af (patch) | |
tree | 656db8df0719d224b830acdefdb08019b1b61db6 /pkg/domain/infra/abi/containers.go | |
parent | a1d5a518d3e9db785b7f15e07c679b9ae041ccae (diff) | |
download | podman-22c8270135620bbbeb988076378173e452ec04af.tar.gz podman-22c8270135620bbbeb988076378173e452ec04af.tar.bz2 podman-22c8270135620bbbeb988076378173e452ec04af.zip |
fix podman container exists and diff for storage containers
Current these commands only check if a container exists in libpod. With
this fix, the commands will also check if they are in containers/storage.
This allows users to look at differences within a buildah or CRI-O container.
Currently buildah diff does not exists, so this helps out in that situation
as well as in CRI-O since the cri does not implement a diff command.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi/containers.go')
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 614fd5fe0..191ad8eec 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -74,11 +74,17 @@ func getContainersByContext(all, latest bool, names []string, runtime *libpod.Ru return } -// TODO: Should return *entities.ContainerExistsReport, error +// ContainerExists returns whether the container exists in container storage func (ic *ContainerEngine) ContainerExists(ctx context.Context, nameOrID string) (*entities.BoolReport, error) { _, err := ic.Libpod.LookupContainer(nameOrID) - if err != nil && errors.Cause(err) != define.ErrNoSuchCtr { - return nil, err + if err != nil { + if errors.Cause(err) != define.ErrNoSuchCtr { + return nil, err + } + // Check if container exists in storage + if _, storageErr := ic.Libpod.StorageContainer(nameOrID); storageErr == nil { + err = nil + } } return &entities.BoolReport{Value: err == nil}, nil } |