diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-11-18 22:51:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 22:51:52 +0100 |
commit | b1007caca5abbf1e9f223b4e67428b74ee5f91ef (patch) | |
tree | 03f1591c1baf956a2345e68144d121fa8373c53a /pkg/api/handlers | |
parent | 4434bd797842c3015c0e6132eaf2509fed370c26 (diff) | |
parent | 3b6d7a3669e15a9b66df258b83ad5f4ab67a15f6 (diff) | |
download | podman-b1007caca5abbf1e9f223b4e67428b74ee5f91ef.tar.gz podman-b1007caca5abbf1e9f223b4e67428b74ee5f91ef.tar.bz2 podman-b1007caca5abbf1e9f223b4e67428b74ee5f91ef.zip |
Merge pull request #8379 from rhatdan/remote2
Remove build \!remote flags from test phase 2
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r-- | pkg/api/handlers/compat/networks.go | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 64ddebf9c..c74cdb840 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -289,25 +289,44 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) { func RemoveNetwork(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) - config, err := runtime.GetConfig() - if err != nil { - utils.InternalServerError(w, err) + ic := abi.ContainerEngine{Libpod: runtime} + + query := struct { + Force bool `schema:"force"` + }{ + // This is where you can override the golang default value for one of fields + } + + decoder := r.Context().Value("decoder").(*schema.Decoder) + if err := decoder.Decode(&query, r.URL.Query()); err != nil { + utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) return } + + options := entities.NetworkRmOptions{ + Force: query.Force, + } + name := utils.GetName(r) - exists, err := network.Exists(config, name) + reports, err := ic.NetworkRm(r.Context(), []string{name}, options) if err != nil { - utils.InternalServerError(w, err) + utils.Error(w, "remove Network failed", http.StatusInternalServerError, err) return } - if !exists { - utils.Error(w, "network not found", http.StatusNotFound, define.ErrNoSuchNetwork) + if len(reports) == 0 { + utils.Error(w, "remove Network failed", http.StatusInternalServerError, errors.Errorf("internal error")) return } - if err := network.RemoveNetwork(config, name); err != nil { - utils.InternalServerError(w, err) + report := reports[0] + if report.Err != nil { + if errors.Cause(report.Err) == define.ErrNoSuchNetwork { + utils.Error(w, "network not found", http.StatusNotFound, define.ErrNoSuchNetwork) + return + } + utils.InternalServerError(w, report.Err) return } + utils.WriteResponse(w, http.StatusNoContent, "") } |