summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod/containers.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-10-03 06:56:42 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-10-15 09:51:15 -0400
commit22c8270135620bbbeb988076378173e452ec04af (patch)
tree656db8df0719d224b830acdefdb08019b1b61db6 /pkg/api/handlers/libpod/containers.go
parenta1d5a518d3e9db785b7f15e07c679b9ae041ccae (diff)
downloadpodman-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/api/handlers/libpod/containers.go')
-rw-r--r--pkg/api/handlers/libpod/containers.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/pkg/api/handlers/libpod/containers.go b/pkg/api/handlers/libpod/containers.go
index 7dde51102..8068ea1b8 100644
--- a/pkg/api/handlers/libpod/containers.go
+++ b/pkg/api/handlers/libpod/containers.go
@@ -11,6 +11,7 @@ import (
"github.com/containers/podman/v2/pkg/api/handlers/compat"
"github.com/containers/podman/v2/pkg/api/handlers/utils"
"github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/domain/infra/abi"
"github.com/containers/podman/v2/pkg/ps"
"github.com/gorilla/schema"
"github.com/pkg/errors"
@@ -19,8 +20,12 @@ import (
func ContainerExists(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
+ // Now use the ABI implementation to prevent us from having duplicate
+ // code.
+ containerEngine := abi.ContainerEngine{Libpod: runtime}
+
name := utils.GetName(r)
- _, err := runtime.LookupContainer(name)
+ report, err := containerEngine.ContainerExists(r.Context(), name)
if err != nil {
if errors.Cause(err) == define.ErrNoSuchCtr {
utils.ContainerNotFound(w, name, err)
@@ -30,7 +35,11 @@ func ContainerExists(w http.ResponseWriter, r *http.Request) {
return
}
- utils.WriteResponse(w, http.StatusNoContent, "")
+ if report.Value {
+ utils.WriteResponse(w, http.StatusNoContent, "")
+ } else {
+ utils.ContainerNotFound(w, name, define.ErrNoSuchCtr)
+ }
}
func ListContainers(w http.ResponseWriter, r *http.Request) {