remove TODO: Use return type string instead of []string and update func

This commit is contained in:
tanjunchen
2019-12-27 11:45:18 +08:00
parent 305377a2f5
commit 488b94767c
3 changed files with 13 additions and 17 deletions

View File

@@ -59,18 +59,15 @@ type PodNode struct {
}
// FirstAddress returns the first address of the given type of each node.
// TODO: Use return type string instead of []string
func FirstAddress(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string {
hosts := []string{}
func FirstAddress(nodelist *v1.NodeList, addrType v1.NodeAddressType) string {
for _, n := range nodelist.Items {
for _, addr := range n.Status.Addresses {
if addr.Type == addrType && addr.Address != "" {
hosts = append(hosts, addr.Address)
break
return addr.Address
}
}
}
return hosts
return ""
}
// TODO: better to change to a easy read name