This renames the `rotate_xxx` flags to camelBack, for
consistency with other API query-params, such as
`detachKeys`, `noOverwriteDirNonDir`, and `fromImage`.
Also makes this flag accept a wider range of boolean
values ("0", "1", "true", "false"), and throw an error
if an invalid value is passed.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -67,11 +67,23 @@ func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter, |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 | 69 |
var flags types.UpdateFlags |
| 70 |
- if r.URL.Query().Get("rotate_worker_token") == "true" {
|
|
| 71 |
- flags.RotateWorkerToken = true |
|
| 70 |
+ |
|
| 71 |
+ if value := r.URL.Query().Get("rotateWorkerToken"); value != "" {
|
|
| 72 |
+ rot, err := strconv.ParseBool(value) |
|
| 73 |
+ if err != nil {
|
|
| 74 |
+ return fmt.Errorf("invalid value for rotateWorkerToken: %s", value)
|
|
| 75 |
+ } |
|
| 76 |
+ |
|
| 77 |
+ flags.RotateWorkerToken = rot |
|
| 72 | 78 |
} |
| 73 |
- if r.URL.Query().Get("rotate_manager_token") == "true" {
|
|
| 74 |
- flags.RotateManagerToken = true |
|
| 79 |
+ |
|
| 80 |
+ if value := r.URL.Query().Get("rotateManagerToken"); value != "" {
|
|
| 81 |
+ rot, err := strconv.ParseBool(value) |
|
| 82 |
+ if err != nil {
|
|
| 83 |
+ return fmt.Errorf("invalid value for rotateManagerToken: %s", value)
|
|
| 84 |
+ } |
|
| 85 |
+ |
|
| 86 |
+ flags.RotateManagerToken = rot |
|
| 75 | 87 |
} |
| 76 | 88 |
|
| 77 | 89 |
if err := sr.backend.Update(version, swarm, flags); err != nil {
|
| ... | ... |
@@ -3755,8 +3755,8 @@ Update a Swarm |
| 3755 | 3755 |
|
| 3756 | 3756 |
- **version** – The version number of the swarm object being updated. This is |
| 3757 | 3757 |
required to avoid conflicting writes. |
| 3758 |
-- **rotate_worker_token** - Set to `true` to rotate the worker join token. |
|
| 3759 |
-- **rotate_manager_token** - Set to `true` to rotate the manager join token. |
|
| 3758 |
+- **rotateWorkerToken** - Set to `true` (or `1`) to rotate the worker join token. |
|
| 3759 |
+- **rotateManagerToken** - Set to `true` (or `1`) to rotate the manager join token. |
|
| 3760 | 3760 |
|
| 3761 | 3761 |
**Status codes**: |
| 3762 | 3762 |
|
| ... | ... |
@@ -3756,8 +3756,8 @@ Update a Swarm |
| 3756 | 3756 |
|
| 3757 | 3757 |
- **version** – The version number of the swarm object being updated. This is |
| 3758 | 3758 |
required to avoid conflicting writes. |
| 3759 |
-- **rotate_worker_token** - Set to `true` to rotate the worker join token. |
|
| 3760 |
-- **rotate_manager_token** - Set to `true` to rotate the manager join token. |
|
| 3759 |
+- **rotateWorkerToken** - Set to `true` (or `1`) to rotate the worker join token. |
|
| 3760 |
+- **rotateManagerToken** - Set to `true` (or `1`) to rotate the manager join token. |
|
| 3761 | 3761 |
|
| 3762 | 3762 |
**Status codes**: |
| 3763 | 3763 |
|
| ... | ... |
@@ -270,7 +270,7 @@ func (d *SwarmDaemon) rotateTokens(c *check.C) {
|
| 270 | 270 |
c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out)))
|
| 271 | 271 |
c.Assert(json.Unmarshal(out, &sw), checker.IsNil) |
| 272 | 272 |
|
| 273 |
- url := fmt.Sprintf("/swarm/update?version=%d&rotate_worker_token=true&rotate_manager_token=true", sw.Version.Index)
|
|
| 273 |
+ url := fmt.Sprintf("/swarm/update?version=%d&rotateWorkerToken=true&rotateManagerToken=true", sw.Version.Index)
|
|
| 274 | 274 |
status, out, err = d.SockRequest("POST", url, sw.Spec)
|
| 275 | 275 |
c.Assert(err, checker.IsNil) |
| 276 | 276 |
c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out)))
|