mirror of
https://github.com/docker/compose.git
synced 2025-04-08 17:05:13 +02:00
Merge pull request #272 from docker/fix_port_convert_panic
Trying to fix defensively a panic @nebuk89 encountered on ACI,
This commit is contained in:
commit
e904ac86ad
@ -37,7 +37,7 @@ func ToPorts(ipAddr *containerinstance.IPAddress, ports []containerinstance.Cont
|
||||
protocol = string(port.Protocol)
|
||||
}
|
||||
ip := ""
|
||||
if ipAddr != nil {
|
||||
if ipAddr != nil && ipAddr.IP != nil {
|
||||
ip = *ipAddr.IP
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,26 @@ func TestPortConvert(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with nil ip value",
|
||||
ip: &containerinstance.IPAddress{
|
||||
IP: nil,
|
||||
},
|
||||
ports: []containerinstance.ContainerPort{
|
||||
{
|
||||
Protocol: "tcp",
|
||||
Port: to.Int32Ptr(80),
|
||||
},
|
||||
},
|
||||
expected: []containers.Port{
|
||||
{
|
||||
HostPort: 80,
|
||||
ContainerPort: 80,
|
||||
HostIP: "",
|
||||
Protocol: "tcp",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "skip nil ports",
|
||||
ip: nil,
|
||||
|
Loading…
x
Reference in New Issue
Block a user