Skip to content

Commit 47f91f4

Browse files
committed
fixup! use better code from suggestion
1 parent 09e5e62 commit 47f91f4

File tree

1 file changed

+4
-12
lines changed
  • pkg/handlers/generic/mutation/controlplanevirtualip/providers

1 file changed

+4
-12
lines changed

pkg/handlers/generic/mutation/controlplanevirtualip/providers/providers.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,14 @@ func templateValues(
4242

4343
// If specified, use the virtual IP address and/or port,
4444
// otherwise fall back to the control plane endpoint host and port.
45-
address := controlPlaneEndpoint.Host
46-
port := controlPlaneEndpoint.Port
45+
var virtualIPConfig v1alpha1.ControlPlaneVirtualIPConfiguration
4746
if controlPlaneEndpoint.VirtualIPSpec != nil &&
4847
controlPlaneEndpoint.VirtualIPSpec.Configuration != nil {
49-
address = cmp.Or(
50-
controlPlaneEndpoint.VirtualIPSpec.Configuration.Address,
51-
controlPlaneEndpoint.Host,
52-
)
53-
port = cmp.Or(
54-
controlPlaneEndpoint.VirtualIPSpec.Configuration.Port,
55-
controlPlaneEndpoint.Port,
56-
)
48+
virtualIPConfig = *controlPlaneEndpoint.VirtualIPSpec.Configuration
5749
}
5850
templateInput := input{
59-
Address: address,
60-
Port: port,
51+
Address: cmp.Or(virtualIPConfig.Address, controlPlaneEndpoint.Host),
52+
Port: cmp.Or(virtualIPConfig.Port, controlPlaneEndpoint.Port),
6153
}
6254

6355
var b bytes.Buffer

0 commit comments

Comments
 (0)