Skip to content

Commit

Permalink
trim whitespace from the ip address (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkumatag authored Mar 2, 2022
1 parent a958584 commit bcb0b1e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cloud/scope/powervs_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/base64"
"fmt"
"strconv"
"strings"

"k8s.io/utils/pointer"

Expand Down Expand Up @@ -372,14 +373,16 @@ func (m *PowerVSMachineScope) SetAddresses(instance *models.PVMInstance) {
Address: *instance.ServerName,
})
for _, network := range instance.Networks {
addresses = append(addresses, corev1.NodeAddress{
Type: corev1.NodeInternalIP,
Address: network.IPAddress,
})
if network.ExternalIP != "" {
if strings.TrimSpace(network.IPAddress) != "" {
addresses = append(addresses, corev1.NodeAddress{
Type: corev1.NodeInternalIP,
Address: strings.TrimSpace(network.IPAddress),
})
}
if strings.TrimSpace(network.ExternalIP) != "" {
addresses = append(addresses, corev1.NodeAddress{
Type: corev1.NodeExternalIP,
Address: network.ExternalIP,
Address: strings.TrimSpace(network.ExternalIP),
})
}
}
Expand Down

0 comments on commit bcb0b1e

Please sign in to comment.