mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.
Remove these imports in preparation of migrating our code to become an
actual go module.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
33 lines
878 B
Go
33 lines
878 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
"github.com/docker/docker/api/types/filters"
|
|
"github.com/docker/docker/api/types/network"
|
|
)
|
|
|
|
// NetworkList returns the list of networks configured in the docker host.
|
|
func (cli *Client) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
|
|
query := url.Values{}
|
|
if options.Filters.Len() > 0 {
|
|
//nolint:staticcheck // ignore SA1019 for old code
|
|
filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
query.Set("filters", filterJSON)
|
|
}
|
|
var networkResources []network.Summary
|
|
resp, err := cli.get(ctx, "/networks", query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return networkResources, err
|
|
}
|
|
err = json.NewDecoder(resp.Body).Decode(&networkResources)
|
|
return networkResources, err
|
|
}
|