(ctx context.Context, apiClient client.NodeAPIClient, nodes []string, mergeNode func(node *swarm.Node) error, success func(nodeID string))
| 55 | } |
| 56 | |
| 57 | func updateNodes(ctx context.Context, apiClient client.NodeAPIClient, nodes []string, mergeNode func(node *swarm.Node) error, success func(nodeID string)) error { |
| 58 | for _, nodeID := range nodes { |
| 59 | res, err := apiClient.NodeInspect(ctx, nodeID, client.NodeInspectOptions{}) |
| 60 | if err != nil { |
| 61 | return err |
| 62 | } |
| 63 | |
| 64 | err = mergeNode(&res.Node) |
| 65 | if err != nil { |
| 66 | if errors.Is(err, errNoRoleChange) { |
| 67 | continue |
| 68 | } |
| 69 | return err |
| 70 | } |
| 71 | _, err = apiClient.NodeUpdate(ctx, res.Node.ID, client.NodeUpdateOptions{ |
| 72 | Version: res.Node.Version, |
| 73 | Spec: res.Node.Spec, |
| 74 | }) |
| 75 | if err != nil { |
| 76 | return err |
| 77 | } |
| 78 | success(nodeID) |
| 79 | } |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | func mergeNodeUpdate(flags *pflag.FlagSet) func(*swarm.Node) error { |
| 84 | return func(node *swarm.Node) error { |
no test coverage detected
searching dependent graphs…