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

Function newUpdateCommand

cli/command/node/update.go:24–49  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

22var errNoRoleChange = errors.New("role was already set to the requested value")
23
24func newUpdateCommand(dockerCLI command.Cli) *cobra.Command {
25 options := newNodeOptions()
26
27 cmd := &cobra.Command{
28 Use: "update [OPTIONS] NODE",
29 Short: "Update a node",
30 Args: cli.ExactArgs(1),
31 RunE: func(cmd *cobra.Command, args []string) error {
32 return runUpdate(cmd.Context(), dockerCLI, cmd.Flags(), args[0])
33 },
34 ValidArgsFunction: completeNodeNames(dockerCLI),
35 DisableFlagsInUseLine: true,
36 }
37
38 flags := cmd.Flags()
39 flags.StringVar(&options.role, flagRole, "", `Role of the node ("worker", "manager")`)
40 flags.StringVar(&options.availability, flagAvailability, "", `Availability of the node ("active", "pause", "drain")`)
41 flags.Var(&options.annotations.labels, flagLabelAdd, `Add or update a node label ("key=value")`)
42 labelKeys := opts.NewListOpts(nil)
43 flags.Var(&labelKeys, flagLabelRemove, "Remove a node label if exists")
44
45 _ = cmd.RegisterFlagCompletionFunc(flagRole, completion.FromList("worker", "manager"))
46 _ = cmd.RegisterFlagCompletionFunc(flagAvailability, completion.FromList("active", "pause", "drain"))
47
48 return cmd
49}
50
51func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, nodeID string) error {
52 return updateNodes(ctx, dockerCLI.Client(), []string{nodeID}, mergeNodeUpdate(flags), func(_ string) {

Callers 3

newNodeCommandFunction · 0.70
TestNodeUpdateErrorsFunction · 0.70
TestNodeUpdateFunction · 0.70

Calls 3

newNodeOptionsFunction · 0.85
completeNodeNamesFunction · 0.85
runUpdateFunction · 0.70

Tested by 2

TestNodeUpdateErrorsFunction · 0.56
TestNodeUpdateFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…