swarm_update.go 718 B

12345678910111213141516171819202122
  1. package client
  2. import (
  3. "fmt"
  4. "net/url"
  5. "strconv"
  6. "github.com/docker/docker/api/types/swarm"
  7. "golang.org/x/net/context"
  8. )
  9. // SwarmUpdate updates the swarm.
  10. func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
  11. query := url.Values{}
  12. query.Set("version", strconv.FormatUint(version.Index, 10))
  13. query.Set("rotateWorkerToken", fmt.Sprintf("%v", flags.RotateWorkerToken))
  14. query.Set("rotateManagerToken", fmt.Sprintf("%v", flags.RotateManagerToken))
  15. query.Set("rotateManagerUnlockKey", fmt.Sprintf("%v", flags.RotateManagerUnlockKey))
  16. resp, err := cli.post(ctx, "/swarm/update", query, swarm, nil)
  17. ensureReaderClosed(resp)
  18. return err
  19. }