Change "rotate_worker_token" to "rotateWorkerToken"
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>
This commit is contained in:
parent
771cf83807
commit
bd81df1278
4 changed files with 21 additions and 9 deletions
|
@ -67,11 +67,23 @@ func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter,
|
|||
}
|
||||
|
||||
var flags types.UpdateFlags
|
||||
if r.URL.Query().Get("rotate_worker_token") == "true" {
|
||||
flags.RotateWorkerToken = true
|
||||
|
||||
if value := r.URL.Query().Get("rotateWorkerToken"); value != "" {
|
||||
rot, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid value for rotateWorkerToken: %s", value)
|
||||
}
|
||||
|
||||
flags.RotateWorkerToken = rot
|
||||
}
|
||||
if r.URL.Query().Get("rotate_manager_token") == "true" {
|
||||
flags.RotateManagerToken = true
|
||||
|
||||
if value := r.URL.Query().Get("rotateManagerToken"); value != "" {
|
||||
rot, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid value for rotateManagerToken: %s", value)
|
||||
}
|
||||
|
||||
flags.RotateManagerToken = rot
|
||||
}
|
||||
|
||||
if err := sr.backend.Update(version, swarm, flags); err != nil {
|
||||
|
|
|
@ -3755,8 +3755,8 @@ Update a Swarm
|
|||
|
||||
- **version** – The version number of the swarm object being updated. This is
|
||||
required to avoid conflicting writes.
|
||||
- **rotate_worker_token** - Set to `true` to rotate the worker join token.
|
||||
- **rotate_manager_token** - Set to `true` to rotate the manager join token.
|
||||
- **rotateWorkerToken** - Set to `true` (or `1`) to rotate the worker join token.
|
||||
- **rotateManagerToken** - Set to `true` (or `1`) to rotate the manager join token.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
|
|
@ -3756,8 +3756,8 @@ Update a Swarm
|
|||
|
||||
- **version** – The version number of the swarm object being updated. This is
|
||||
required to avoid conflicting writes.
|
||||
- **rotate_worker_token** - Set to `true` to rotate the worker join token.
|
||||
- **rotate_manager_token** - Set to `true` to rotate the manager join token.
|
||||
- **rotateWorkerToken** - Set to `true` (or `1`) to rotate the worker join token.
|
||||
- **rotateManagerToken** - Set to `true` (or `1`) to rotate the manager join token.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ func (d *SwarmDaemon) rotateTokens(c *check.C) {
|
|||
c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out)))
|
||||
c.Assert(json.Unmarshal(out, &sw), checker.IsNil)
|
||||
|
||||
url := fmt.Sprintf("/swarm/update?version=%d&rotate_worker_token=true&rotate_manager_token=true", sw.Version.Index)
|
||||
url := fmt.Sprintf("/swarm/update?version=%d&rotateWorkerToken=true&rotateManagerToken=true", sw.Version.Index)
|
||||
status, out, err = d.SockRequest("POST", url, sw.Spec)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out)))
|
||||
|
|
Loading…
Reference in a new issue