daemon: Daemon.buildSandboxOptions: use range when looping
Makes the code slightly more readable. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
33b4285eb1
commit
2b028dc55b
1 changed files with 5 additions and 6 deletions
|
@ -121,26 +121,25 @@ func (daemon *Daemon) buildSandboxOptions(cfg *config.Config, container *contain
|
|||
Port: portNum,
|
||||
})
|
||||
|
||||
binding := bindings[port]
|
||||
for i := 0; i < len(binding); i++ {
|
||||
newP, err := nat.NewPort(nat.SplitProtoPort(binding[i].HostPort))
|
||||
for _, binding := range bindings[port] {
|
||||
newP, err := nat.NewPort(nat.SplitProtoPort(binding.HostPort))
|
||||
var portStart, portEnd int
|
||||
if err == nil {
|
||||
portStart, portEnd, err = newP.Range()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error parsing HostPort value(%s):%v", binding[i].HostPort, err)
|
||||
return nil, fmt.Errorf("Error parsing HostPort value(%s):%v", binding.HostPort, err)
|
||||
}
|
||||
publishedPorts = append(publishedPorts, types.PortBinding{
|
||||
Proto: portProto,
|
||||
Port: portNum,
|
||||
HostIP: net.ParseIP(binding[i].HostIP),
|
||||
HostIP: net.ParseIP(binding.HostIP),
|
||||
HostPort: uint16(portStart),
|
||||
HostPortEnd: uint16(portEnd),
|
||||
})
|
||||
}
|
||||
|
||||
if container.HostConfig.PublishAllPorts && len(binding) == 0 {
|
||||
if container.HostConfig.PublishAllPorts && len(bindings[port]) == 0 {
|
||||
publishedPorts = append(publishedPorts, types.PortBinding{
|
||||
Proto: portProto,
|
||||
Port: portNum,
|
||||
|
|
Loading…
Reference in a new issue