diff options
author | Charlie Doern <cdoern@redhat.com> | 2021-06-08 15:47:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-08 15:47:44 -0400 |
commit | da1bade294025a419877484ae35f352984e804d2 (patch) | |
tree | cbc2e03595a15cdaa19870ebb00e5248a1360aa0 /pkg/api/handlers/compat | |
parent | 9938557a53ed6599267ed1f8c0b6378499ab8e28 (diff) | |
parent | 5117deda04b765cd3dc7bd454286764a7c1ea6bc (diff) | |
download | podman-da1bade294025a419877484ae35f352984e804d2.tar.gz podman-da1bade294025a419877484ae35f352984e804d2.tar.bz2 podman-da1bade294025a419877484ae35f352984e804d2.zip |
Merge pull request #10603 from cdoern/networksQuery
implemented verbose and scope as possible
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/networks.go | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 04f8570ff..4e1f31404 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -28,19 +28,24 @@ import ( func InspectNetwork(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) - // FYI scope and version are currently unused but are described by the API - // Leaving this for if/when we have to enable these - // query := struct { - // scope string - // verbose bool - // }{ - // // override any golang type defaults - // } - // 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 - // } + // scope is only used to see if the user passes any illegal value, verbose is not used but implemented + // for compatibility purposes only. + query := struct { + scope string `schema:"scope"` + verbose bool `schema:"verbose"` + }{ + scope: "local", + } + 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 + } + + if query.scope != "local" { + utils.Error(w, "Invalid scope value. Can only be local.", http.StatusBadRequest, define.ErrInvalidArg) + return + } config, err := runtime.GetConfig() if err != nil { utils.InternalServerError(w, err) |