mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client/node: Wrap options and output
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -8,17 +8,21 @@ import (
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
)
|
||||
|
||||
type NodeListResult struct {
|
||||
Items []swarm.Node
|
||||
}
|
||||
|
||||
// NodeList returns the list of nodes.
|
||||
func (cli *Client) NodeList(ctx context.Context, options NodeListOptions) ([]swarm.Node, error) {
|
||||
func (cli *Client) NodeList(ctx context.Context, options NodeListOptions) (NodeListResult, 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
|
||||
return NodeListResult{}, err
|
||||
}
|
||||
|
||||
var nodes []swarm.Node
|
||||
err = json.NewDecoder(resp.Body).Decode(&nodes)
|
||||
return nodes, err
|
||||
return NodeListResult{Items: nodes}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user