mirror of
https://github.com/moby/moby.git
synced 2026-01-11 02:31:44 +00:00
Align with the other swarm-types, which use `Spec` for updates. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
31 lines
728 B
Go
31 lines
728 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
|
|
"github.com/moby/moby/api/types/swarm"
|
|
)
|
|
|
|
// NodeUpdateOptions holds parameters to update nodes with.
|
|
type NodeUpdateOptions struct {
|
|
Version swarm.Version
|
|
Spec swarm.NodeSpec
|
|
}
|
|
|
|
type NodeUpdateResult struct{}
|
|
|
|
// NodeUpdate updates a Node.
|
|
func (cli *Client) NodeUpdate(ctx context.Context, nodeID string, options NodeUpdateOptions) (NodeUpdateResult, error) {
|
|
nodeID, err := trimID("node", nodeID)
|
|
if err != nil {
|
|
return NodeUpdateResult{}, err
|
|
}
|
|
|
|
query := url.Values{}
|
|
query.Set("version", options.Version.String())
|
|
resp, err := cli.post(ctx, "/nodes/"+nodeID+"/update", query, options.Spec, nil)
|
|
defer ensureReaderClosed(resp)
|
|
return NodeUpdateResult{}, err
|
|
}
|