From 4e7adc1c0ac8f52a50c9cd45543cc0da47243df7 Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Wed, 2 Mar 2022 16:12:30 +0530 Subject: [PATCH] trim whitespace from the ip address --- cloud/scope/powervs_machine.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cloud/scope/powervs_machine.go b/cloud/scope/powervs_machine.go index 88fe4a85f..49e5d1b95 100644 --- a/cloud/scope/powervs_machine.go +++ b/cloud/scope/powervs_machine.go @@ -21,6 +21,7 @@ import ( "encoding/base64" "fmt" "strconv" + "strings" "k8s.io/utils/pointer" @@ -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), }) } }