mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: refactor ServiceCreate, ServiceUpdate, SwarmUpdate
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>
This commit is contained in:
@@ -10,7 +10,8 @@ import (
|
||||
|
||||
// SwarmUpdateOptions contains options for updating a swarm.
|
||||
type SwarmUpdateOptions struct {
|
||||
Swarm swarm.Spec
|
||||
Version swarm.Version
|
||||
Spec swarm.Spec
|
||||
RotateWorkerToken bool
|
||||
RotateManagerToken bool
|
||||
RotateManagerUnlockKey bool
|
||||
@@ -20,13 +21,13 @@ type SwarmUpdateOptions struct {
|
||||
type SwarmUpdateResult struct{}
|
||||
|
||||
// SwarmUpdate updates the swarm.
|
||||
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, options SwarmUpdateOptions) (SwarmUpdateResult, error) {
|
||||
func (cli *Client) SwarmUpdate(ctx context.Context, options SwarmUpdateOptions) (SwarmUpdateResult, error) {
|
||||
query := url.Values{}
|
||||
query.Set("version", version.String())
|
||||
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.Swarm, nil)
|
||||
resp, err := cli.post(ctx, "/swarm/update", query, options.Spec, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
return SwarmUpdateResult{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user