mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Remove --network-add and --network-rm flags from service update
These flags were not supported (daemon returns an error), and it was an oversight. They were not present in completion scripts. Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
5947bf461f
commit
3a7e90c743
4 changed files with 0 additions and 40 deletions
|
@ -538,8 +538,6 @@ const (
|
||||||
flagMountAdd = "mount-add"
|
flagMountAdd = "mount-add"
|
||||||
flagName = "name"
|
flagName = "name"
|
||||||
flagNetwork = "network"
|
flagNetwork = "network"
|
||||||
flagNetworkRemove = "network-rm"
|
|
||||||
flagNetworkAdd = "network-add"
|
|
||||||
flagPublish = "publish"
|
flagPublish = "publish"
|
||||||
flagPublishRemove = "publish-rm"
|
flagPublishRemove = "publish-rm"
|
||||||
flagPublishAdd = "publish-add"
|
flagPublishAdd = "publish-add"
|
||||||
|
|
|
@ -42,14 +42,12 @@ func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
flags.Var(newListOptsVar(), flagContainerLabelRemove, "Remove a container label by its key")
|
flags.Var(newListOptsVar(), flagContainerLabelRemove, "Remove a container label by its key")
|
||||||
flags.Var(newListOptsVar(), flagMountRemove, "Remove a mount by its target path")
|
flags.Var(newListOptsVar(), flagMountRemove, "Remove a mount by its target path")
|
||||||
flags.Var(newListOptsVar(), flagPublishRemove, "Remove a published port by its target port")
|
flags.Var(newListOptsVar(), flagPublishRemove, "Remove a published port by its target port")
|
||||||
flags.Var(newListOptsVar(), flagNetworkRemove, "Remove a network by name")
|
|
||||||
flags.Var(newListOptsVar(), flagConstraintRemove, "Remove a constraint")
|
flags.Var(newListOptsVar(), flagConstraintRemove, "Remove a constraint")
|
||||||
flags.Var(&opts.labels, flagLabelAdd, "Add or update service labels")
|
flags.Var(&opts.labels, flagLabelAdd, "Add or update service labels")
|
||||||
flags.Var(&opts.containerLabels, flagContainerLabelAdd, "Add or update container labels")
|
flags.Var(&opts.containerLabels, flagContainerLabelAdd, "Add or update container labels")
|
||||||
flags.Var(&opts.env, flagEnvAdd, "Add or update environment variables")
|
flags.Var(&opts.env, flagEnvAdd, "Add or update environment variables")
|
||||||
flags.Var(&opts.mounts, flagMountAdd, "Add or update a mount on a service")
|
flags.Var(&opts.mounts, flagMountAdd, "Add or update a mount on a service")
|
||||||
flags.StringSliceVar(&opts.constraints, flagConstraintAdd, []string{}, "Add or update placement constraints")
|
flags.StringSliceVar(&opts.constraints, flagConstraintAdd, []string{}, "Add or update placement constraints")
|
||||||
flags.StringSliceVar(&opts.networks, flagNetworkAdd, []string{}, "Add or update network attachments")
|
|
||||||
flags.Var(&opts.endpoint.ports, flagPublishAdd, "Add or update a published port")
|
flags.Var(&opts.endpoint.ports, flagPublishAdd, "Add or update a published port")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -204,7 +202,6 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error {
|
||||||
updateString(flagUpdateFailureAction, &spec.UpdateConfig.FailureAction)
|
updateString(flagUpdateFailureAction, &spec.UpdateConfig.FailureAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNetworks(flags, &spec.Networks)
|
|
||||||
if flags.Changed(flagEndpointMode) {
|
if flags.Changed(flagEndpointMode) {
|
||||||
value, _ := flags.GetString(flagEndpointMode)
|
value, _ := flags.GetString(flagEndpointMode)
|
||||||
if spec.EndpointSpec == nil {
|
if spec.EndpointSpec == nil {
|
||||||
|
@ -439,23 +436,6 @@ func equalPort(targetPort nat.Port, port swarm.PortConfig) bool {
|
||||||
port.TargetPort == uint32(targetPort.Int()))
|
port.TargetPort == uint32(targetPort.Int()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateNetworks(flags *pflag.FlagSet, attachments *[]swarm.NetworkAttachmentConfig) {
|
|
||||||
if flags.Changed(flagNetworkAdd) {
|
|
||||||
networks, _ := flags.GetStringSlice(flagNetworkAdd)
|
|
||||||
for _, network := range networks {
|
|
||||||
*attachments = append(*attachments, swarm.NetworkAttachmentConfig{Target: network})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
toRemove := buildToRemoveSet(flags, flagNetworkRemove)
|
|
||||||
newNetworks := []swarm.NetworkAttachmentConfig{}
|
|
||||||
for _, network := range *attachments {
|
|
||||||
if _, exists := toRemove[network.Target]; !exists {
|
|
||||||
newNetworks = append(newNetworks, network)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*attachments = newNetworks
|
|
||||||
}
|
|
||||||
|
|
||||||
func updateReplicas(flags *pflag.FlagSet, serviceMode *swarm.ServiceMode) error {
|
func updateReplicas(flags *pflag.FlagSet, serviceMode *swarm.ServiceMode) error {
|
||||||
if !flags.Changed(flagReplicas) {
|
if !flags.Changed(flagReplicas) {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -115,22 +115,6 @@ func TestUpdateMounts(t *testing.T) {
|
||||||
assert.Equal(t, mounts[1].Target, "/toadd")
|
assert.Equal(t, mounts[1].Target, "/toadd")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateNetworks(t *testing.T) {
|
|
||||||
flags := newUpdateCommand(nil).Flags()
|
|
||||||
flags.Set("network-add", "toadd")
|
|
||||||
flags.Set("network-rm", "toremove")
|
|
||||||
|
|
||||||
attachments := []swarm.NetworkAttachmentConfig{
|
|
||||||
{Target: "toremove", Aliases: []string{"foo"}},
|
|
||||||
{Target: "tokeep"},
|
|
||||||
}
|
|
||||||
|
|
||||||
updateNetworks(flags, &attachments)
|
|
||||||
assert.Equal(t, len(attachments), 2)
|
|
||||||
assert.Equal(t, attachments[0].Target, "tokeep")
|
|
||||||
assert.Equal(t, attachments[1].Target, "toadd")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdatePorts(t *testing.T) {
|
func TestUpdatePorts(t *testing.T) {
|
||||||
flags := newUpdateCommand(nil).Flags()
|
flags := newUpdateCommand(nil).Flags()
|
||||||
flags.Set("publish-add", "1000:1000")
|
flags.Set("publish-add", "1000:1000")
|
||||||
|
|
|
@ -35,8 +35,6 @@ Options:
|
||||||
--mount-add value Add or update a mount on a service
|
--mount-add value Add or update a mount on a service
|
||||||
--mount-rm value Remove a mount by its target path (default [])
|
--mount-rm value Remove a mount by its target path (default [])
|
||||||
--name string Service name
|
--name string Service name
|
||||||
--network-add value Add or update network attachments (default [])
|
|
||||||
--network-rm value Remove a network by name (default [])
|
|
||||||
--publish-add value Add or update a published port (default [])
|
--publish-add value Add or update a published port (default [])
|
||||||
--publish-rm value Remove a published port by its target port (default [])
|
--publish-rm value Remove a published port by its target port (default [])
|
||||||
--replicas value Number of tasks (default none)
|
--replicas value Number of tasks (default none)
|
||||||
|
|
Loading…
Reference in a new issue