diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-01-21 15:31:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 15:31:32 -0500 |
commit | 6fd83de31dab0c60932972c6b26f68fa0bd1871f (patch) | |
tree | d017ed4d59da4a0f0b703430d60b2d2f43484aaa /pkg/api/handlers | |
parent | 3ba1a8de8649db2f5cdde80d0f4cf02370e10b8a (diff) | |
parent | 9d31fed5f75186f618e95ab7492ef6bc2b511d5f (diff) | |
download | podman-6fd83de31dab0c60932972c6b26f68fa0bd1871f.tar.gz podman-6fd83de31dab0c60932972c6b26f68fa0bd1871f.tar.bz2 podman-6fd83de31dab0c60932972c6b26f68fa0bd1871f.zip |
Merge pull request #9027 from Luap99/podman-volume-exists
Podman volume exists
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r-- | pkg/api/handlers/libpod/volumes.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/api/handlers/libpod/volumes.go b/pkg/api/handlers/libpod/volumes.go index 38fdf1b4d..1a8759c6c 100644 --- a/pkg/api/handlers/libpod/volumes.go +++ b/pkg/api/handlers/libpod/volumes.go @@ -11,6 +11,7 @@ import ( "github.com/containers/podman/v2/pkg/domain/entities" "github.com/containers/podman/v2/pkg/domain/entities/reports" "github.com/containers/podman/v2/pkg/domain/filters" + "github.com/containers/podman/v2/pkg/domain/infra/abi" "github.com/containers/podman/v2/pkg/domain/infra/abi/parse" "github.com/gorilla/schema" "github.com/pkg/errors" @@ -203,3 +204,21 @@ func RemoveVolume(w http.ResponseWriter, r *http.Request) { } utils.WriteResponse(w, http.StatusNoContent, "") } + +// ExistsVolume check if a volume exists +func ExistsVolume(w http.ResponseWriter, r *http.Request) { + runtime := r.Context().Value("runtime").(*libpod.Runtime) + name := utils.GetName(r) + + ic := abi.ContainerEngine{Libpod: runtime} + report, err := ic.VolumeExists(r.Context(), name) + if err != nil { + utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err) + return + } + if !report.Value { + utils.Error(w, "volume not found", http.StatusNotFound, define.ErrNoSuchVolume) + return + } + utils.WriteResponse(w, http.StatusNoContent, "") +} |