summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-01-18 18:52:06 +0100
committerPaul Holzinger <paul.holzinger@web.de>2021-01-19 15:18:03 +0100
commita45d22a1ddd2840cf8c3a38540aa8683cc0d5c7d (patch)
treedfda1d8d5f64baa183dc0f166e2441d8719b1cc8 /pkg/api/handlers/libpod
parent5b3c7a52939275784c45c9747dd5864bd0581ff5 (diff)
downloadpodman-a45d22a1ddd2840cf8c3a38540aa8683cc0d5c7d.tar.gz
podman-a45d22a1ddd2840cf8c3a38540aa8683cc0d5c7d.tar.bz2
podman-a45d22a1ddd2840cf8c3a38540aa8683cc0d5c7d.zip
podman network exists
Add podman network exists command with remote support. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r--pkg/api/handlers/libpod/networks.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/api/handlers/libpod/networks.go b/pkg/api/handlers/libpod/networks.go
index 8511e2733..d3bf06988 100644
--- a/pkg/api/handlers/libpod/networks.go
+++ b/pkg/api/handlers/libpod/networks.go
@@ -157,3 +157,21 @@ func Connect(w http.ResponseWriter, r *http.Request) {
}
utils.WriteResponse(w, http.StatusOK, "OK")
}
+
+// ExistsNetwork check if a network exists
+func ExistsNetwork(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.NetworkExists(r.Context(), name)
+ if err != nil {
+ utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ return
+ }
+ if !report.Value {
+ utils.Error(w, "network not found", http.StatusNotFound, define.ErrNoSuchNetwork)
+ return
+ }
+ utils.WriteResponse(w, http.StatusNoContent, "")
+}