Trying to fix defensively a panic @nebuk89 encountered on ACI, but could not reproduce it.

This commit is contained in:
Guillaume Tardif 2020-06-23 17:52:14 +02:00
parent 6b31b91f18
commit 70f9613dab
2 changed files with 21 additions and 1 deletions

View File

@ -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
}

View File

@ -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,