mirror of https://github.com/docker/compose.git
Trying to fix defensively a panic @nebuk89 encountered on ACI, but could not reproduce it.
This commit is contained in:
parent
6b31b91f18
commit
70f9613dab
|
@ -37,7 +37,7 @@ func ToPorts(ipAddr *containerinstance.IPAddress, ports []containerinstance.Cont
|
||||||
protocol = string(port.Protocol)
|
protocol = string(port.Protocol)
|
||||||
}
|
}
|
||||||
ip := ""
|
ip := ""
|
||||||
if ipAddr != nil {
|
if ipAddr != nil && ipAddr.IP != nil {
|
||||||
ip = *ipAddr.IP
|
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",
|
name: "skip nil ports",
|
||||||
ip: nil,
|
ip: nil,
|
||||||
|
|
Loading…
Reference in New Issue