mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Change the add/update flags to include 'add'
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
ead1f62aba
commit
4c6faa4340
5 changed files with 68 additions and 49 deletions
|
@ -28,7 +28,15 @@ func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
flags.StringVar(&opts.mode, flagMode, "replicated", "Service mode (replicated or global)")
|
flags.StringVar(&opts.mode, flagMode, "replicated", "Service mode (replicated or global)")
|
||||||
addServiceFlags(cmd, opts)
|
addServiceFlags(cmd, opts)
|
||||||
cmd.Flags().SetInterspersed(false)
|
|
||||||
|
flags.VarP(&opts.labels, flagLabel, "l", "Service labels")
|
||||||
|
flags.VarP(&opts.env, flagEnv, "e", "Set environment variables")
|
||||||
|
flags.Var(&opts.mounts, flagMount, "Attach a mount to the service")
|
||||||
|
flags.StringSliceVar(&opts.constraints, flagConstraint, []string{}, "Placement constraints")
|
||||||
|
flags.StringSliceVar(&opts.networks, flagNetwork, []string{}, "Network attachments")
|
||||||
|
flags.VarP(&opts.endpoint.ports, flagPublish, "p", "Publish a port as a node port")
|
||||||
|
|
||||||
|
flags.SetInterspersed(false)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -459,12 +459,9 @@ func (opts *serviceOptions) ToService() (swarm.ServiceSpec, error) {
|
||||||
func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
|
func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
flags.StringVar(&opts.name, flagName, "", "Service name")
|
flags.StringVar(&opts.name, flagName, "", "Service name")
|
||||||
flags.VarP(&opts.labels, flagLabel, "l", "Service labels")
|
|
||||||
|
|
||||||
flags.VarP(&opts.env, flagEnv, "e", "Set environment variables")
|
|
||||||
flags.StringVarP(&opts.workdir, "workdir", "w", "", "Working directory inside the container")
|
flags.StringVarP(&opts.workdir, "workdir", "w", "", "Working directory inside the container")
|
||||||
flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID")
|
flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID")
|
||||||
flags.Var(&opts.mounts, flagMount, "Attach a mount to the service")
|
|
||||||
|
|
||||||
flags.Var(&opts.resources.limitCPU, flagLimitCPU, "Limit CPUs")
|
flags.Var(&opts.resources.limitCPU, flagLimitCPU, "Limit CPUs")
|
||||||
flags.Var(&opts.resources.limitMemBytes, flagLimitMemory, "Limit Memory")
|
flags.Var(&opts.resources.limitMemBytes, flagLimitMemory, "Limit Memory")
|
||||||
|
@ -479,36 +476,38 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
|
||||||
flags.Var(&opts.restartPolicy.maxAttempts, flagRestartMaxAttempts, "Maximum number of restarts before giving up")
|
flags.Var(&opts.restartPolicy.maxAttempts, flagRestartMaxAttempts, "Maximum number of restarts before giving up")
|
||||||
flags.Var(&opts.restartPolicy.window, flagRestartWindow, "Window used to evaluate the restart policy")
|
flags.Var(&opts.restartPolicy.window, flagRestartWindow, "Window used to evaluate the restart policy")
|
||||||
|
|
||||||
flags.StringSliceVar(&opts.constraints, flagConstraint, []string{}, "Placement constraints")
|
|
||||||
|
|
||||||
flags.Uint64Var(&opts.update.parallelism, flagUpdateParallelism, 0, "Maximum number of tasks updated simultaneously")
|
flags.Uint64Var(&opts.update.parallelism, flagUpdateParallelism, 0, "Maximum number of tasks updated simultaneously")
|
||||||
flags.DurationVar(&opts.update.delay, flagUpdateDelay, time.Duration(0), "Delay between updates")
|
flags.DurationVar(&opts.update.delay, flagUpdateDelay, time.Duration(0), "Delay between updates")
|
||||||
|
|
||||||
flags.StringSliceVar(&opts.networks, flagNetwork, []string{}, "Network attachments")
|
|
||||||
flags.StringVar(&opts.endpoint.mode, flagEndpointMode, "", "Endpoint mode (vip or dnsrr)")
|
flags.StringVar(&opts.endpoint.mode, flagEndpointMode, "", "Endpoint mode (vip or dnsrr)")
|
||||||
flags.VarP(&opts.endpoint.ports, flagPublish, "p", "Publish a port as a node port")
|
|
||||||
|
|
||||||
flags.BoolVar(&opts.registryAuth, flagRegistryAuth, false, "Send registry authentication details to Swarm agents")
|
flags.BoolVar(&opts.registryAuth, flagRegistryAuth, false, "Send registry authentication details to Swarm agents")
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
flagConstraint = "constraint"
|
flagConstraint = "constraint"
|
||||||
flagConstraintRemove = "remove-constraint"
|
flagConstraintRemove = "constraint-rm"
|
||||||
|
flagConstraintAdd = "constraint-add"
|
||||||
flagEndpointMode = "endpoint-mode"
|
flagEndpointMode = "endpoint-mode"
|
||||||
flagEnv = "env"
|
flagEnv = "env"
|
||||||
flagEnvRemove = "remove-env"
|
flagEnvRemove = "env-rm"
|
||||||
|
flagEnvAdd = "env-add"
|
||||||
flagLabel = "label"
|
flagLabel = "label"
|
||||||
flagLabelRemove = "remove-label"
|
flagLabelRemove = "label-rm"
|
||||||
|
flagLabelAdd = "label-add"
|
||||||
flagLimitCPU = "limit-cpu"
|
flagLimitCPU = "limit-cpu"
|
||||||
flagLimitMemory = "limit-memory"
|
flagLimitMemory = "limit-memory"
|
||||||
flagMode = "mode"
|
flagMode = "mode"
|
||||||
flagMount = "mount"
|
flagMount = "mount"
|
||||||
flagMountRemove = "remove-mount"
|
flagMountRemove = "mount-rm"
|
||||||
|
flagMountAdd = "mount-add"
|
||||||
flagName = "name"
|
flagName = "name"
|
||||||
flagNetwork = "network"
|
flagNetwork = "network"
|
||||||
flagNetworkRemove = "remove-network"
|
flagNetworkRemove = "network-rm"
|
||||||
|
flagNetworkAdd = "network-add"
|
||||||
flagPublish = "publish"
|
flagPublish = "publish"
|
||||||
flagPublishRemove = "remove-publish"
|
flagPublishRemove = "publish-rm"
|
||||||
|
flagPublishAdd = "publish-add"
|
||||||
flagReplicas = "replicas"
|
flagReplicas = "replicas"
|
||||||
flagReserveCPU = "reserve-cpu"
|
flagReserveCPU = "reserve-cpu"
|
||||||
flagReserveMemory = "reserve-memory"
|
flagReserveMemory = "reserve-memory"
|
||||||
|
|
|
@ -35,15 +35,26 @@ func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
flags.String("image", "", "Service image tag")
|
flags.String("image", "", "Service image tag")
|
||||||
flags.String("args", "", "Service command args")
|
flags.String("args", "", "Service command args")
|
||||||
addServiceFlags(cmd, opts)
|
addServiceFlags(cmd, opts)
|
||||||
flags.StringSlice(flagEnvRemove, []string{}, "Remove an environment variable")
|
|
||||||
flags.StringSlice(flagLabelRemove, []string{}, "Remove a label by its key")
|
flags.Var(newListOptsVar(), flagEnvRemove, "Remove an environment variable")
|
||||||
flags.StringSlice(flagMountRemove, []string{}, "Remove a mount by its target path")
|
flags.Var(newListOptsVar(), flagLabelRemove, "Remove a label by its key")
|
||||||
flags.StringSlice(flagPublishRemove, []string{}, "Remove a published port by its target port")
|
flags.Var(newListOptsVar(), flagMountRemove, "Remove a mount by its target path")
|
||||||
flags.StringSlice(flagNetworkRemove, []string{}, "Remove a network by name")
|
flags.Var(newListOptsVar(), flagPublishRemove, "Remove a published port by its target port")
|
||||||
flags.StringSlice(flagConstraintRemove, []string{}, "Remove a constraint")
|
flags.Var(newListOptsVar(), flagNetworkRemove, "Remove a network by name")
|
||||||
|
flags.Var(newListOptsVar(), flagConstraintRemove, "Remove a constraint")
|
||||||
|
flags.Var(&opts.labels, flagLabelAdd, "Add or update service labels")
|
||||||
|
flags.Var(&opts.env, flagEnvAdd, "Add or update environment variables")
|
||||||
|
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.networks, flagNetworkAdd, []string{}, "Add or update network attachments")
|
||||||
|
flags.Var(&opts.endpoint.ports, flagPublishAdd, "Add or update a published port")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newListOptsVar() *opts.ListOpts {
|
||||||
|
return opts.NewListOptsRef(&[]string{}, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, serviceID string) error {
|
func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, serviceID string) error {
|
||||||
apiClient := dockerCli.Client()
|
apiClient := dockerCli.Client()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -176,7 +187,7 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error {
|
||||||
updateDurationOpt((flagRestartWindow), task.RestartPolicy.Window)
|
updateDurationOpt((flagRestartWindow), task.RestartPolicy.Window)
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.Changed(flagConstraint) {
|
if anyChanged(flags, flagConstraintAdd, flagConstraintRemove) {
|
||||||
if task.Placement == nil {
|
if task.Placement == nil {
|
||||||
task.Placement = &swarm.Placement{}
|
task.Placement = &swarm.Placement{}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +212,7 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error {
|
||||||
spec.EndpointSpec.Mode = swarm.ResolutionMode(value)
|
spec.EndpointSpec.Mode = swarm.ResolutionMode(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.Changed(flagPublish) {
|
if anyChanged(flags, flagPublishAdd, flagPublishRemove) {
|
||||||
if spec.EndpointSpec == nil {
|
if spec.EndpointSpec == nil {
|
||||||
spec.EndpointSpec = &swarm.EndpointSpec{}
|
spec.EndpointSpec = &swarm.EndpointSpec{}
|
||||||
}
|
}
|
||||||
|
@ -231,7 +242,7 @@ func anyChanged(flags *pflag.FlagSet, fields ...string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updatePlacement(flags *pflag.FlagSet, placement *swarm.Placement) {
|
func updatePlacement(flags *pflag.FlagSet, placement *swarm.Placement) {
|
||||||
field, _ := flags.GetStringSlice(flagConstraint)
|
field, _ := flags.GetStringSlice(flagConstraintAdd)
|
||||||
constraints := &placement.Constraints
|
constraints := &placement.Constraints
|
||||||
placement.Constraints = append(placement.Constraints, field...)
|
placement.Constraints = append(placement.Constraints, field...)
|
||||||
|
|
||||||
|
@ -244,19 +255,19 @@ func updatePlacement(flags *pflag.FlagSet, placement *swarm.Placement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateLabels(flags *pflag.FlagSet, field *map[string]string) {
|
func updateLabels(flags *pflag.FlagSet, field *map[string]string) {
|
||||||
if flags.Changed(flagLabel) {
|
if flags.Changed(flagLabelAdd) {
|
||||||
if field == nil {
|
if field == nil {
|
||||||
*field = map[string]string{}
|
*field = map[string]string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
values := flags.Lookup(flagLabel).Value.(*opts.ListOpts).GetAll()
|
values := flags.Lookup(flagLabelAdd).Value.(*opts.ListOpts).GetAll()
|
||||||
for key, value := range runconfigopts.ConvertKVStringsToMap(values) {
|
for key, value := range runconfigopts.ConvertKVStringsToMap(values) {
|
||||||
(*field)[key] = value
|
(*field)[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if field != nil && flags.Changed(flagLabelRemove) {
|
if field != nil && flags.Changed(flagLabelRemove) {
|
||||||
toRemove, _ := flags.GetStringSlice(flagLabelRemove)
|
toRemove := flags.Lookup(flagLabelRemove).Value.(*opts.ListOpts).GetAll()
|
||||||
for _, label := range toRemove {
|
for _, label := range toRemove {
|
||||||
delete(*field, label)
|
delete(*field, label)
|
||||||
}
|
}
|
||||||
|
@ -264,8 +275,8 @@ func updateLabels(flags *pflag.FlagSet, field *map[string]string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
||||||
if flags.Changed(flagEnv) {
|
if flags.Changed(flagEnvAdd) {
|
||||||
value := flags.Lookup(flagEnv).Value.(*opts.ListOpts)
|
value := flags.Lookup(flagEnvAdd).Value.(*opts.ListOpts)
|
||||||
*field = append(*field, value.GetAll()...)
|
*field = append(*field, value.GetAll()...)
|
||||||
}
|
}
|
||||||
toRemove := buildToRemoveSet(flags, flagEnvRemove)
|
toRemove := buildToRemoveSet(flags, flagEnvRemove)
|
||||||
|
@ -290,7 +301,7 @@ func buildToRemoveSet(flags *pflag.FlagSet, flag string) map[string]struct{} {
|
||||||
return toRemove
|
return toRemove
|
||||||
}
|
}
|
||||||
|
|
||||||
toRemoveSlice, _ := flags.GetStringSlice(flag)
|
toRemoveSlice := flags.Lookup(flag).Value.(*opts.ListOpts).GetAll()
|
||||||
for _, key := range toRemoveSlice {
|
for _, key := range toRemoveSlice {
|
||||||
toRemove[key] = empty
|
toRemove[key] = empty
|
||||||
}
|
}
|
||||||
|
@ -298,8 +309,8 @@ func buildToRemoveSet(flags *pflag.FlagSet, flag string) map[string]struct{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateMounts(flags *pflag.FlagSet, mounts *[]swarm.Mount) {
|
func updateMounts(flags *pflag.FlagSet, mounts *[]swarm.Mount) {
|
||||||
if flags.Changed(flagMount) {
|
if flags.Changed(flagMountAdd) {
|
||||||
values := flags.Lookup(flagMount).Value.(*MountOpt).Value()
|
values := flags.Lookup(flagMountAdd).Value.(*MountOpt).Value()
|
||||||
*mounts = append(*mounts, values...)
|
*mounts = append(*mounts, values...)
|
||||||
}
|
}
|
||||||
toRemove := buildToRemoveSet(flags, flagMountRemove)
|
toRemove := buildToRemoveSet(flags, flagMountRemove)
|
||||||
|
@ -311,8 +322,8 @@ func updateMounts(flags *pflag.FlagSet, mounts *[]swarm.Mount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updatePorts(flags *pflag.FlagSet, portConfig *[]swarm.PortConfig) {
|
func updatePorts(flags *pflag.FlagSet, portConfig *[]swarm.PortConfig) {
|
||||||
if flags.Changed(flagPublish) {
|
if flags.Changed(flagPublishAdd) {
|
||||||
values := flags.Lookup(flagPublish).Value.(*opts.ListOpts).GetAll()
|
values := flags.Lookup(flagPublishAdd).Value.(*opts.ListOpts).GetAll()
|
||||||
ports, portBindings, _ := nat.ParsePortSpecs(values)
|
ports, portBindings, _ := nat.ParsePortSpecs(values)
|
||||||
|
|
||||||
for port := range ports {
|
for port := range ports {
|
||||||
|
@ -321,13 +332,14 @@ func updatePorts(flags *pflag.FlagSet, portConfig *[]swarm.PortConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.Changed(flagPublishRemove) {
|
if flags.Changed(flagPublishRemove) {
|
||||||
toRemove, _ := flags.GetStringSlice(flagPublishRemove)
|
toRemove := flags.Lookup(flagPublishRemove).Value.(*opts.ListOpts).GetAll()
|
||||||
for _, rawTargetPort := range toRemove {
|
for _, rawTargetPort := range toRemove {
|
||||||
targetPort := nat.Port(rawTargetPort)
|
targetPort := nat.Port(rawTargetPort)
|
||||||
for i, port := range *portConfig {
|
for i, port := range *portConfig {
|
||||||
if string(port.Protocol) == targetPort.Proto() &&
|
if string(port.Protocol) == targetPort.Proto() &&
|
||||||
port.TargetPort == uint32(targetPort.Int()) {
|
port.TargetPort == uint32(targetPort.Int()) {
|
||||||
*portConfig = append((*portConfig)[:i], (*portConfig)[i+1:]...)
|
*portConfig = append((*portConfig)[:i], (*portConfig)[i+1:]...)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,8 +347,8 @@ func updatePorts(flags *pflag.FlagSet, portConfig *[]swarm.PortConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateNetworks(flags *pflag.FlagSet, attachments *[]swarm.NetworkAttachmentConfig) {
|
func updateNetworks(flags *pflag.FlagSet, attachments *[]swarm.NetworkAttachmentConfig) {
|
||||||
if flags.Changed(flagNetwork) {
|
if flags.Changed(flagNetworkAdd) {
|
||||||
networks, _ := flags.GetStringSlice(flagNetwork)
|
networks, _ := flags.GetStringSlice(flagNetworkAdd)
|
||||||
for _, network := range networks {
|
for _, network := range networks {
|
||||||
*attachments = append(*attachments, swarm.NetworkAttachmentConfig{Target: network})
|
*attachments = append(*attachments, swarm.NetworkAttachmentConfig{Target: network})
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ func TestUpdateServiceArgs(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdateLabels(t *testing.T) {
|
func TestUpdateLabels(t *testing.T) {
|
||||||
flags := newUpdateCommand(nil).Flags()
|
flags := newUpdateCommand(nil).Flags()
|
||||||
flags.Set("label", "toadd=newlabel")
|
flags.Set("label-add", "toadd=newlabel")
|
||||||
flags.Set("remove-label", "toremove")
|
flags.Set("label-rm", "toremove")
|
||||||
|
|
||||||
labels := map[string]string{
|
labels := map[string]string{
|
||||||
"toremove": "thelabeltoremove",
|
"toremove": "thelabeltoremove",
|
||||||
|
@ -37,8 +37,8 @@ func TestUpdateLabels(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdatePlacement(t *testing.T) {
|
func TestUpdatePlacement(t *testing.T) {
|
||||||
flags := newUpdateCommand(nil).Flags()
|
flags := newUpdateCommand(nil).Flags()
|
||||||
flags.Set("constraint", "node=toadd")
|
flags.Set("constraint-add", "node=toadd")
|
||||||
flags.Set("remove-constraint", "node!=toremove")
|
flags.Set("constraint-rm", "node!=toremove")
|
||||||
|
|
||||||
placement := &swarm.Placement{
|
placement := &swarm.Placement{
|
||||||
Constraints: []string{"node!=toremove", "container=tokeep"},
|
Constraints: []string{"node!=toremove", "container=tokeep"},
|
||||||
|
@ -52,8 +52,8 @@ func TestUpdatePlacement(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdateEnvironment(t *testing.T) {
|
func TestUpdateEnvironment(t *testing.T) {
|
||||||
flags := newUpdateCommand(nil).Flags()
|
flags := newUpdateCommand(nil).Flags()
|
||||||
flags.Set("env", "toadd=newenv")
|
flags.Set("env-add", "toadd=newenv")
|
||||||
flags.Set("remove-env", "toremove")
|
flags.Set("env-rm", "toremove")
|
||||||
|
|
||||||
envs := []string{"toremove=theenvtoremove", "tokeep=value"}
|
envs := []string{"toremove=theenvtoremove", "tokeep=value"}
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ func TestUpdateEnvironment(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdateMounts(t *testing.T) {
|
func TestUpdateMounts(t *testing.T) {
|
||||||
flags := newUpdateCommand(nil).Flags()
|
flags := newUpdateCommand(nil).Flags()
|
||||||
flags.Set("mount", "type=volume,target=/toadd")
|
flags.Set("mount-add", "type=volume,target=/toadd")
|
||||||
flags.Set("remove-mount", "/toremove")
|
flags.Set("mount-rm", "/toremove")
|
||||||
|
|
||||||
mounts := []swarm.Mount{
|
mounts := []swarm.Mount{
|
||||||
{Target: "/toremove", Type: swarm.MountType("BIND")},
|
{Target: "/toremove", Type: swarm.MountType("BIND")},
|
||||||
|
@ -81,8 +81,8 @@ func TestUpdateMounts(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdateNetworks(t *testing.T) {
|
func TestUpdateNetworks(t *testing.T) {
|
||||||
flags := newUpdateCommand(nil).Flags()
|
flags := newUpdateCommand(nil).Flags()
|
||||||
flags.Set("network", "toadd")
|
flags.Set("network-add", "toadd")
|
||||||
flags.Set("remove-network", "toremove")
|
flags.Set("network-rm", "toremove")
|
||||||
|
|
||||||
attachments := []swarm.NetworkAttachmentConfig{
|
attachments := []swarm.NetworkAttachmentConfig{
|
||||||
{Target: "toremove", Aliases: []string{"foo"}},
|
{Target: "toremove", Aliases: []string{"foo"}},
|
||||||
|
@ -97,8 +97,8 @@ func TestUpdateNetworks(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdatePorts(t *testing.T) {
|
func TestUpdatePorts(t *testing.T) {
|
||||||
flags := newUpdateCommand(nil).Flags()
|
flags := newUpdateCommand(nil).Flags()
|
||||||
flags.Set("publish", "1000:1000")
|
flags.Set("publish-add", "1000:1000")
|
||||||
flags.Set("remove-publish", "333/udp")
|
flags.Set("publish-rm", "333/udp")
|
||||||
|
|
||||||
portConfigs := []swarm.PortConfig{
|
portConfigs := []swarm.PortConfig{
|
||||||
{TargetPort: 333, Protocol: swarm.PortConfigProtocol("udp")},
|
{TargetPort: 333, Protocol: swarm.PortConfigProtocol("udp")},
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (s *DockerSwarmSuite) TestServiceUpdatePort(c *check.C) {
|
||||||
waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 1)
|
waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 1)
|
||||||
|
|
||||||
// Update the service: changed the port mapping from 8080:8081 to 8082:8083.
|
// Update the service: changed the port mapping from 8080:8081 to 8082:8083.
|
||||||
_, err = d.Cmd("service", "update", "-p", "8082:8083", "--remove-publish", "8081", serviceName)
|
_, err = d.Cmd("service", "update", "--publish-add", "8082:8083", "--publish-rm", "8081", serviceName)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// Inspect the service and verify port mapping
|
// Inspect the service and verify port mapping
|
||||||
|
|
Loading…
Add table
Reference in a new issue