diff --git a/azure/convert/ports.go b/azure/convert/ports.go index b6fd12d3..6c0f7090 100644 --- a/azure/convert/ports.go +++ b/azure/convert/ports.go @@ -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 } diff --git a/azure/convert/ports_test.go b/azure/convert/ports_test.go index cce29d30..78af6ed6 100644 --- a/azure/convert/ports_test.go +++ b/azure/convert/ports_test.go @@ -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,