@@ -447,11 +447,12 @@ func reconcileNetworkComponents(log logr.Logger, osProviderClient *gophercloud.P
447
447
448
448
// Calculate the port that we will use for the API server
449
449
var apiServerPort int
450
- if openStackCluster .Spec .ControlPlaneEndpoint .IsValid () {
450
+ switch {
451
+ case openStackCluster .Spec .ControlPlaneEndpoint .IsValid ():
451
452
apiServerPort = int (openStackCluster .Spec .ControlPlaneEndpoint .Port )
452
- } else if openStackCluster .Spec .APIServerPort != 0 {
453
+ case openStackCluster .Spec .APIServerPort != 0 :
453
454
apiServerPort = openStackCluster .Spec .APIServerPort
454
- } else {
455
+ default :
455
456
apiServerPort = 6443
456
457
}
457
458
@@ -471,21 +472,22 @@ func reconcileNetworkComponents(log logr.Logger, osProviderClient *gophercloud.P
471
472
if ! openStackCluster .Spec .ControlPlaneEndpoint .IsValid () {
472
473
var host string
473
474
// If there is a load balancer use the floating IP for it if set, falling back to the internal IP
474
- if openStackCluster .Spec .ManagedAPIServerLoadBalancer {
475
+ switch {
476
+ case openStackCluster .Spec .ManagedAPIServerLoadBalancer :
475
477
if openStackCluster .Status .Network .APIServerLoadBalancer .IP != "" {
476
478
host = openStackCluster .Status .Network .APIServerLoadBalancer .IP
477
479
} else {
478
480
host = openStackCluster .Status .Network .APIServerLoadBalancer .InternalIP
479
481
}
480
- } else if ! openStackCluster .Spec .DisableAPIServerFloatingIP {
482
+ case ! openStackCluster .Spec .DisableAPIServerFloatingIP :
481
483
// If floating IPs are not disabled, get one to use as the VIP for the control plane
482
484
fp , err := networkingService .GetOrCreateFloatingIP (openStackCluster , clusterName , openStackCluster .Spec .APIServerFloatingIP )
483
485
if err != nil {
484
486
handleUpdateOSCError (openStackCluster , errors .Errorf ("Floating IP cannot be got or created: %v" , err ))
485
487
return errors .Errorf ("Floating IP cannot be got or created: %v" , err )
486
488
}
487
489
host = fp .FloatingIP
488
- } else {
490
+ default :
489
491
// This case is not managed for now (i.e. no load balancer + no floating IP)
490
492
// We could manage a VIP port on the cluster network and set allowedAddressPairs accordingly
491
493
// when creating control plane machines, but this would require us to deploy software on the
0 commit comments