MCPcopy Index your code
hub / github.com/docker/cli / updateNodes

Function updateNodes

cli/command/node/update.go:57–81  ·  view source on GitHub ↗
(ctx context.Context, apiClient client.NodeAPIClient, nodes []string, mergeNode func(node *swarm.Node) error, success func(nodeID string))

Source from the content-addressed store, hash-verified

55}
56
57func 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
83func mergeNodeUpdate(flags *pflag.FlagSet) func(*swarm.Node) error {
84 return func(node *swarm.Node) error {

Callers 3

runDemoteFunction · 0.85
runUpdateFunction · 0.85
runPromoteFunction · 0.85

Calls 2

NodeUpdateMethod · 0.80
NodeInspectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…