mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
Add a new type to use for building filter predicates for API requests, replacing "./api/types/filters".Args in the client. Remove the now unused api/types/filters package. Signed-off-by: Cory Snider <csnider@mirantis.com>
25 lines
522 B
Go
25 lines
522 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
"github.com/moby/moby/api/types/swarm"
|
|
)
|
|
|
|
// NodeList returns the list of nodes.
|
|
func (cli *Client) NodeList(ctx context.Context, options NodeListOptions) ([]swarm.Node, error) {
|
|
query := url.Values{}
|
|
options.Filters.updateURLValues(query)
|
|
resp, err := cli.get(ctx, "/nodes", query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var nodes []swarm.Node
|
|
err = json.NewDecoder(resp.Body).Decode(&nodes)
|
|
return nodes, err
|
|
}
|