Browse code

Remove --name flag from service update

The --name flag was inadvertently added to
docker service update, but is not supported,
as it has various side-effects (e.g., existing
tasks are not renamed).

This removes the flag from the service update
command.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2016/09/28 19:34:31
Showing 8 changed files
... ...
@@ -27,6 +27,8 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
27 27
 	}
28 28
 	flags := cmd.Flags()
29 29
 	flags.StringVar(&opts.mode, flagMode, "replicated", "Service mode (replicated or global)")
30
+	flags.StringVar(&opts.name, flagName, "", "Service name")
31
+
30 32
 	addServiceFlags(cmd, opts)
31 33
 
32 34
 	flags.VarP(&opts.labels, flagLabel, "l", "Service labels")
... ...
@@ -490,7 +490,6 @@ func (opts *serviceOptions) ToService() (swarm.ServiceSpec, error) {
490 490
 // Any flags that are not common are added separately in the individual command
491 491
 func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
492 492
 	flags := cmd.Flags()
493
-	flags.StringVar(&opts.name, flagName, "", "Service name")
494 493
 
495 494
 	flags.StringVarP(&opts.workdir, flagWorkdir, "w", "", "Working directory inside the container")
496 495
 	flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
... ...
@@ -172,7 +172,6 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error {
172 172
 		return task.Resources
173 173
 	}
174 174
 
175
-	updateString(flagName, &spec.Name)
176 175
 	updateLabels(flags, &spec.Labels)
177 176
 	updateContainerLabels(flags, &cspec.Labels)
178 177
 	updateString("image", &cspec.Image)
... ...
@@ -2672,7 +2672,6 @@ _docker_service_update() {
2672 2672
 		--log-driver
2673 2673
 		--log-opt
2674 2674
 		--mount
2675
-		--name
2676 2675
 		--network
2677 2676
 		--publish -p
2678 2677
 		--replicas
... ...
@@ -2704,6 +2703,7 @@ _docker_service_update() {
2704 2704
 		options_with_args="$options_with_args
2705 2705
 			--container-label
2706 2706
 			--mode
2707
+			--name
2707 2708
 		"
2708 2709
 
2709 2710
 		case "$prev" in
... ...
@@ -1095,7 +1095,6 @@ __docker_service_subcommand() {
1095 1095
         "($help)--log-driver=[Logging driver for service]:logging driver:__docker_log_drivers"
1096 1096
         "($help)*--log-opt=[Logging driver options]:log driver options:__docker_log_options"
1097 1097
         "($help)*--mount=[Attach a mount to the service]:mount: "
1098
-        "($help)--name=[Service name]:name: "
1099 1098
         "($help)*--network=[Network attachments]:network: "
1100 1099
         "($help)*"{-p=,--publish=}"[Publish a port as a node port]:port: "
1101 1100
         "($help)--replicas=[Number of tasks]:replicas: "
... ...
@@ -1123,6 +1122,7 @@ __docker_service_subcommand() {
1123 1123
                 $opts_create_update \
1124 1124
                 "($help)*--container-label=[Container labels]:label: " \
1125 1125
                 "($help)--mode=[Service Mode]:mode:(global replicated)" \
1126
+                "($help)--name=[Service name]:name: " \
1126 1127
                 "($help -): :__docker_images" \
1127 1128
                 "($help -):command: _command_names -e" \
1128 1129
                 "($help -)*::arguments: _normal" && ret=0
... ...
@@ -4846,7 +4846,7 @@ image](#create-an-image) section for more details.
4846 4846
 
4847 4847
 **JSON Parameters**:
4848 4848
 
4849
-- **Name** – User-defined name for the service.
4849
+- **Name** – User-defined name for the service. Note that renaming services is not supported.
4850 4850
 - **Labels** – A map of labels to associate with the service (e.g., `{"key":"value", "key2":"value2"}`).
4851 4851
 - **TaskTemplate** – Specification of the tasks to start as part of the new service.
4852 4852
     - **ContainerSpec** - Container settings for containers started as part of this task.
... ...
@@ -5375,7 +5375,7 @@ image](#create-an-image) section for more details.
5375 5375
 
5376 5376
 **JSON Parameters**:
5377 5377
 
5378
-- **Name** – User-defined name for the service.
5378
+- **Name** – User-defined name for the service. Note that renaming services is not supported.
5379 5379
 - **Labels** – A map of labels to associate with the service (e.g., `{"key":"value", "key2":"value2"}`).
5380 5380
 - **TaskTemplate** – Specification of the tasks to start as part of the new service.
5381 5381
     - **ContainerSpec** - Container settings for containers started as part of this task.
... ...
@@ -42,7 +42,6 @@ Options:
42 42
       --log-opt value                    Logging driver options (default [])
43 43
       --mount-add value                  Add or update a mount on a service
44 44
       --mount-rm value                   Remove a mount by its target path (default [])
45
-      --name string                      Service name
46 45
       --publish-add value                Add or update a published port (default [])
47 46
       --publish-rm value                 Remove a published port by its target port (default [])
48 47
       --replicas value                   Number of tasks (default none)