Signed-off-by: allencloud <allen.sun@daocloud.io>
| ... | ... |
@@ -1369,7 +1369,7 @@ func (c *Cluster) GetNode(input string) (types.Node, error) {
|
| 1369 | 1369 |
} |
| 1370 | 1370 |
|
| 1371 | 1371 |
// UpdateNode updates existing nodes properties. |
| 1372 |
-func (c *Cluster) UpdateNode(nodeID string, version uint64, spec types.NodeSpec) error {
|
|
| 1372 |
+func (c *Cluster) UpdateNode(input string, version uint64, spec types.NodeSpec) error {
|
|
| 1373 | 1373 |
c.RLock() |
| 1374 | 1374 |
defer c.RUnlock() |
| 1375 | 1375 |
|
| ... | ... |
@@ -1385,10 +1385,15 @@ func (c *Cluster) UpdateNode(nodeID string, version uint64, spec types.NodeSpec) |
| 1385 | 1385 |
ctx, cancel := c.getRequestContext() |
| 1386 | 1386 |
defer cancel() |
| 1387 | 1387 |
|
| 1388 |
+ currentNode, err := getNode(ctx, c.client, input) |
|
| 1389 |
+ if err != nil {
|
|
| 1390 |
+ return err |
|
| 1391 |
+ } |
|
| 1392 |
+ |
|
| 1388 | 1393 |
_, err = c.client.UpdateNode( |
| 1389 | 1394 |
ctx, |
| 1390 | 1395 |
&swarmapi.UpdateNodeRequest{
|
| 1391 |
- NodeID: nodeID, |
|
| 1396 |
+ NodeID: currentNode.ID, |
|
| 1392 | 1397 |
Spec: &nodeSpec, |
| 1393 | 1398 |
NodeVersion: &swarmapi.Version{
|
| 1394 | 1399 |
Index: version, |
| ... | ... |
@@ -193,6 +193,7 @@ This section lists each version from latest to oldest. Each listing includes a |
| 193 | 193 |
* `POST /plugins/(plugin name)/push` push a plugin. |
| 194 | 194 |
* `POST /plugins/create?name=(plugin name)` create a plugin. |
| 195 | 195 |
* `DELETE /plugins/(plugin name)` delete a plugin. |
| 196 |
+* `POST /node/(id or name)/update` now accepts both `id` or `name` to identify the node to update. |
|
| 196 | 197 |
|
| 197 | 198 |
|
| 198 | 199 |
### v1.24 API changes |
| ... | ... |
@@ -3965,7 +3965,7 @@ List nodes |
| 3965 | 3965 |
### Inspect a node |
| 3966 | 3966 |
|
| 3967 | 3967 |
|
| 3968 |
-`GET /nodes/<id>` |
|
| 3968 |
+`GET /nodes/(id or name)` |
|
| 3969 | 3969 |
|
| 3970 | 3970 |
Return low-level information on the node `id` |
| 3971 | 3971 |
|
| ... | ... |
@@ -4047,9 +4047,9 @@ Return low-level information on the node `id` |
| 4047 | 4047 |
### Remove a node |
| 4048 | 4048 |
|
| 4049 | 4049 |
|
| 4050 |
-`DELETE /nodes/(id)` |
|
| 4050 |
+`DELETE /nodes/(id or name)` |
|
| 4051 | 4051 |
|
| 4052 |
-Remove a node [`id`] from the swarm. |
|
| 4052 |
+Remove a node from the swarm. |
|
| 4053 | 4053 |
|
| 4054 | 4054 |
**Example request**: |
| 4055 | 4055 |
|
| ... | ... |
@@ -4077,7 +4077,7 @@ Remove a node [`id`] from the swarm. |
| 4077 | 4077 |
|
| 4078 | 4078 |
`POST /nodes/(id)/update` |
| 4079 | 4079 |
|
| 4080 |
-Update the node `id`. |
|
| 4080 |
+Update a node. |
|
| 4081 | 4081 |
|
| 4082 | 4082 |
The payload of the `POST` request is the new `NodeSpec` and |
| 4083 | 4083 |
overrides the current `NodeSpec` for the specified node. |
| ... | ... |
@@ -4564,7 +4564,7 @@ List nodes |
| 4564 | 4564 |
### Inspect a node |
| 4565 | 4565 |
|
| 4566 | 4566 |
|
| 4567 |
-`GET /nodes/<id>` |
|
| 4567 |
+`GET /nodes/(id or name)` |
|
| 4568 | 4568 |
|
| 4569 | 4569 |
Return low-level information on the node `id` |
| 4570 | 4570 |
|
| ... | ... |
@@ -4647,9 +4647,9 @@ Return low-level information on the node `id` |
| 4647 | 4647 |
### Remove a node |
| 4648 | 4648 |
|
| 4649 | 4649 |
|
| 4650 |
-`DELETE /nodes/(id)` |
|
| 4650 |
+`DELETE /nodes/(id or name)` |
|
| 4651 | 4651 |
|
| 4652 |
-Remove a node [`id`] from the swarm. |
|
| 4652 |
+Remove a node from the swarm. |
|
| 4653 | 4653 |
|
| 4654 | 4654 |
**Example request**: |
| 4655 | 4655 |
|
| ... | ... |
@@ -4675,9 +4675,9 @@ Remove a node [`id`] from the swarm. |
| 4675 | 4675 |
### Update a node |
| 4676 | 4676 |
|
| 4677 | 4677 |
|
| 4678 |
-`POST /nodes/(id)/update` |
|
| 4678 |
+`POST /nodes/(id or name)/update` |
|
| 4679 | 4679 |
|
| 4680 |
-Update the node `id`. |
|
| 4680 |
+Update a node. |
|
| 4681 | 4681 |
|
| 4682 | 4682 |
The payload of the `POST` request is the new `NodeSpec` and |
| 4683 | 4683 |
overrides the current `NodeSpec` for the specified node. |