From 47f91f49a28a6c8508be9ec3a02683ece2562f78 Mon Sep 17 00:00:00 2001 From: Dimitri Koshkin Date: Thu, 5 Dec 2024 15:00:21 -0800 Subject: [PATCH] fixup! use better code from suggestion --- .../controlplanevirtualip/providers/providers.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pkg/handlers/generic/mutation/controlplanevirtualip/providers/providers.go b/pkg/handlers/generic/mutation/controlplanevirtualip/providers/providers.go index 788532dac..16cf993f2 100644 --- a/pkg/handlers/generic/mutation/controlplanevirtualip/providers/providers.go +++ b/pkg/handlers/generic/mutation/controlplanevirtualip/providers/providers.go @@ -42,22 +42,14 @@ func templateValues( // If specified, use the virtual IP address and/or port, // otherwise fall back to the control plane endpoint host and port. - address := controlPlaneEndpoint.Host - port := controlPlaneEndpoint.Port + var virtualIPConfig v1alpha1.ControlPlaneVirtualIPConfiguration if controlPlaneEndpoint.VirtualIPSpec != nil && controlPlaneEndpoint.VirtualIPSpec.Configuration != nil { - address = cmp.Or( - controlPlaneEndpoint.VirtualIPSpec.Configuration.Address, - controlPlaneEndpoint.Host, - ) - port = cmp.Or( - controlPlaneEndpoint.VirtualIPSpec.Configuration.Port, - controlPlaneEndpoint.Port, - ) + virtualIPConfig = *controlPlaneEndpoint.VirtualIPSpec.Configuration } templateInput := input{ - Address: address, - Port: port, + Address: cmp.Or(virtualIPConfig.Address, controlPlaneEndpoint.Host), + Port: cmp.Or(virtualIPConfig.Port, controlPlaneEndpoint.Port), } var b bytes.Buffer