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

Function newUpdateCommand

cli/command/service/update.go:32–144  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

30)
31
32func newUpdateCommand(dockerCLI command.Cli) *cobra.Command {
33 options := newServiceOptions()
34
35 cmd := &cobra.Command{
36 Use: "update [OPTIONS] SERVICE",
37 Short: "Update a service",
38 Args: cli.ExactArgs(1),
39 RunE: func(cmd *cobra.Command, args []string) error {
40 return runUpdate(cmd.Context(), dockerCLI, cmd.Flags(), options, args[0])
41 },
42 ValidArgsFunction: completeServiceNames(dockerCLI),
43 DisableFlagsInUseLine: true,
44 }
45
46 flags := cmd.Flags()
47 flags.String("image", "", "Service image tag")
48 flags.Var(&ShlexOpt{}, "args", "Service command args")
49 flags.Bool(flagRollback, false, "Rollback to previous specification")
50 _ = flags.SetAnnotation(flagRollback, "version", []string{"1.25"})
51 flags.Bool("force", false, "Force update even if no changes require it")
52 _ = flags.SetAnnotation("force", "version", []string{"1.25"})
53 addServiceFlags(flags, options, nil)
54
55 flags.Var(newListOptsVar(), flagEnvRemove, "Remove an environment variable")
56 flags.Var(newListOptsVar(), flagGroupRemove, "Remove a previously added supplementary user group from the container")
57 _ = flags.SetAnnotation(flagGroupRemove, "version", []string{"1.25"})
58 flags.Var(newListOptsVar(), flagLabelRemove, "Remove a label by its key")
59 flags.Var(newListOptsVar(), flagContainerLabelRemove, "Remove a container label by its key")
60 flags.Var(newListOptsVar(), flagMountRemove, "Remove a mount by its target path")
61 // flags.Var(newListOptsVar().WithValidator(validatePublishRemove), flagPublishRemove, "Remove a published port by its target port")
62 flags.Var(&swarmopts.PortOpt{}, flagPublishRemove, "Remove a published port by its target port")
63 flags.Var(newListOptsVar(), flagConstraintRemove, "Remove a constraint")
64 flags.Var(newListOptsVar(), flagDNSRemove, "Remove a custom DNS server")
65 _ = flags.SetAnnotation(flagDNSRemove, "version", []string{"1.25"})
66 flags.Var(newListOptsVar(), flagDNSOptionRemove, "Remove a DNS option")
67 _ = flags.SetAnnotation(flagDNSOptionRemove, "version", []string{"1.25"})
68 flags.Var(newListOptsVar(), flagDNSSearchRemove, "Remove a DNS search domain")
69 _ = flags.SetAnnotation(flagDNSSearchRemove, "version", []string{"1.25"})
70 flags.Var(newListOptsVar(), flagHostRemove, `Remove a custom host-to-IP mapping ("host:ip")`)
71 _ = flags.SetAnnotation(flagHostRemove, "version", []string{"1.25"})
72 flags.Var(&options.labels, flagLabelAdd, "Add or update a service label")
73 flags.Var(&options.containerLabels, flagContainerLabelAdd, "Add or update a container label")
74 flags.Var(&options.env, flagEnvAdd, "Add or update an environment variable")
75 flags.Var(newListOptsVar(), flagSecretRemove, "Remove a secret")
76 _ = flags.SetAnnotation(flagSecretRemove, "version", []string{"1.25"})
77 flags.Var(&options.secrets, flagSecretAdd, "Add or update a secret on a service")
78 _ = flags.SetAnnotation(flagSecretAdd, "version", []string{"1.25"})
79
80 flags.Var(newListOptsVar(), flagConfigRemove, "Remove a configuration file")
81 _ = flags.SetAnnotation(flagConfigRemove, "version", []string{"1.30"})
82 flags.Var(&options.configs, flagConfigAdd, "Add or update a config file on a service")
83 _ = flags.SetAnnotation(flagConfigAdd, "version", []string{"1.30"})
84
85 flags.Var(&options.mounts, flagMountAdd, "Add or update a mount on a service")
86 flags.Var(&options.constraints, flagConstraintAdd, "Add or update a placement constraint")
87 flags.Var(&options.placementPrefs, flagPlacementPrefAdd, "Add a placement preference")
88 _ = flags.SetAnnotation(flagPlacementPrefAdd, "version", []string{"1.28"})
89 flags.Var(&placementPrefOpts{}, flagPlacementPrefRemove, "Remove a placement preference")

Callers 15

newServiceCommandFunction · 0.70
TestUpdateServiceArgsFunction · 0.70
TestUpdateLabelsFunction · 0.70
TestUpdatePlacementPrefsFunction · 0.70
TestUpdateEnvironmentFunction · 0.70
TestUpdateGroupsFunction · 0.70
TestUpdateDNSConfigFunction · 0.70
TestUpdateMountsFunction · 0.70

Calls 7

newServiceOptionsFunction · 0.85
completeServiceNamesFunction · 0.85
addServiceFlagsFunction · 0.85
newListOptsVarFunction · 0.85
runUpdateFunction · 0.70
StringMethod · 0.65

Tested by 15

TestUpdateServiceArgsFunction · 0.56
TestUpdateLabelsFunction · 0.56
TestUpdatePlacementPrefsFunction · 0.56
TestUpdateEnvironmentFunction · 0.56
TestUpdateGroupsFunction · 0.56
TestUpdateDNSConfigFunction · 0.56
TestUpdateMountsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…