Skip to content

Commit 9c10a9c

Browse files
committed
opts/swarmopts: remove use of nat.ParsePortRange
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 65cf876 commit 9c10a9c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

opts/swarmopts/port.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,17 @@ func ConvertPortToPortConfig(
162162
logrus.Warnf("ignoring IP-address (%s:%s) service will listen on '0.0.0.0'", net.JoinHostPort(binding.HostIP, binding.HostPort), portProto.String())
163163
}
164164

165-
startHostPort, endHostPort, err := nat.ParsePortRange(binding.HostPort)
166-
165+
pr, err := network.ParsePortRange(binding.HostPort)
167166
if err != nil && binding.HostPort != "" {
168167
return nil, fmt.Errorf("invalid hostport binding (%s) for port (%d)", binding.HostPort, portProto.Num())
169168
}
170169

171-
for i := startHostPort; i <= endHostPort; i++ {
170+
for p := range pr.All() {
172171
ports = append(ports, swarm.PortConfig{
173172
// TODO Name: ?
174173
Protocol: portProto.Proto(),
175174
TargetPort: uint32(portProto.Num()),
176-
PublishedPort: uint32(i),
175+
PublishedPort: uint32(p.Num()),
177176
PublishMode: swarm.PortConfigPublishModeIngress,
178177
})
179178
}

0 commit comments

Comments
 (0)