mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
Put the version and spec in the options-struct, as we did for other swarm-related methods. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
"strconv"
|
|
|
|
"github.com/moby/moby/api/types/swarm"
|
|
)
|
|
|
|
// SwarmUpdateOptions contains options for updating a swarm.
|
|
type SwarmUpdateOptions struct {
|
|
Version swarm.Version
|
|
Spec swarm.Spec
|
|
RotateWorkerToken bool
|
|
RotateManagerToken bool
|
|
RotateManagerUnlockKey bool
|
|
}
|
|
|
|
// SwarmUpdateResult represents the result of a SwarmUpdate operation.
|
|
type SwarmUpdateResult struct{}
|
|
|
|
// SwarmUpdate updates the swarm.
|
|
func (cli *Client) SwarmUpdate(ctx context.Context, options SwarmUpdateOptions) (SwarmUpdateResult, error) {
|
|
query := url.Values{}
|
|
query.Set("version", options.Version.String())
|
|
query.Set("rotateWorkerToken", strconv.FormatBool(options.RotateWorkerToken))
|
|
query.Set("rotateManagerToken", strconv.FormatBool(options.RotateManagerToken))
|
|
query.Set("rotateManagerUnlockKey", strconv.FormatBool(options.RotateManagerUnlockKey))
|
|
resp, err := cli.post(ctx, "/swarm/update", query, options.Spec, nil)
|
|
defer ensureReaderClosed(resp)
|
|
return SwarmUpdateResult{}, err
|
|
}
|