diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-01 16:28:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 16:28:51 +0100 |
commit | b5827d80d39f2a9865d7f6486d63e61d5c9926ef (patch) | |
tree | 706a267dd78bbbaef03d6ed0151a029c3342f637 /pkg/api/handlers/compat | |
parent | b154c519ace790f4e0ada60b6e0c6985cf213acb (diff) | |
parent | f54ed7269a99b26a6c8d14c1a0f7be8f038d10ba (diff) | |
download | podman-b5827d80d39f2a9865d7f6486d63e61d5c9926ef.tar.gz podman-b5827d80d39f2a9865d7f6486d63e61d5c9926ef.tar.bz2 podman-b5827d80d39f2a9865d7f6486d63e61d5c9926ef.zip |
Merge pull request #9531 from Luap99/fix-9526
compat api network ls accept both format options
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/networks.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 1a04b4289..28e90ac28 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -180,16 +180,18 @@ func findPluginByName(plugins []*libcni.NetworkConfig, pluginType string) ([]byt func ListNetworks(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) - decoder := r.Context().Value("decoder").(*schema.Decoder) - query := struct { - Filters map[string][]string `schema:"filters"` - }{ - // override any golang type defaults - } - if err := decoder.Decode(&query, r.URL.Query()); err != nil { + filters, err := filtersFromRequest(r) + if err != nil { utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) return } + filterMap := map[string][]string{} + for _, filter := range filters { + split := strings.SplitN(filter, "=", 2) + if len(split) > 1 { + filterMap[split[0]] = append(filterMap[split[0]], split[1]) + } + } config, err := runtime.GetConfig() if err != nil { utils.InternalServerError(w, err) @@ -205,7 +207,7 @@ func ListNetworks(w http.ResponseWriter, r *http.Request) { reports := []*types.NetworkResource{} logrus.Debugf("netNames: %q", strings.Join(netNames, ", ")) for _, name := range netNames { - report, err := getNetworkResourceByNameOrID(name, runtime, query.Filters) + report, err := getNetworkResourceByNameOrID(name, runtime, filterMap) if err != nil { utils.InternalServerError(w, err) return |