Skip to content

Commit 0608fbc

Browse files
authored
Merge pull request #820 from hidekazuna/var_reorder
🏃 Reorder function variables
2 parents cd2fa7f + 9c6f735 commit 0608fbc

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

controllers/openstackcluster_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func reconcileBastion(log logr.Logger, osProviderClient *gophercloud.ProviderCli
323323
return nil
324324
}
325325

326-
instance, err = computeService.CreateBastion(cluster.Name, openStackCluster)
326+
instance, err = computeService.CreateBastion(openStackCluster, cluster.Name)
327327
if err != nil {
328328
return errors.Errorf("failed to reconcile bastion: %v", err)
329329
}
@@ -401,15 +401,15 @@ func reconcileNetworkComponents(log logr.Logger, osProviderClient *gophercloud.P
401401
Tags: subnetList[0].Tags,
402402
}
403403
} else {
404-
err := networkingService.ReconcileNetwork(clusterName, openStackCluster)
404+
err := networkingService.ReconcileNetwork(openStackCluster, clusterName)
405405
if err != nil {
406406
return errors.Errorf("failed to reconcile network: %v", err)
407407
}
408-
err = networkingService.ReconcileSubnet(clusterName, openStackCluster)
408+
err = networkingService.ReconcileSubnet(openStackCluster, clusterName)
409409
if err != nil {
410410
return errors.Errorf("failed to reconcile subnets: %v", err)
411411
}
412-
err = networkingService.ReconcileRouter(clusterName, openStackCluster)
412+
err = networkingService.ReconcileRouter(openStackCluster, clusterName)
413413
if err != nil {
414414
return errors.Errorf("failed to reconcile router: %v", err)
415415
}
@@ -432,13 +432,13 @@ func reconcileNetworkComponents(log logr.Logger, osProviderClient *gophercloud.P
432432
}
433433
}
434434

435-
err = networkingService.ReconcileSecurityGroups(clusterName, openStackCluster)
435+
err = networkingService.ReconcileSecurityGroups(openStackCluster, clusterName)
436436
if err != nil {
437437
return errors.Errorf("failed to reconcile security groups: %v", err)
438438
}
439439

440440
if openStackCluster.Spec.ManagedAPIServerLoadBalancer {
441-
err = loadBalancerService.ReconcileLoadBalancer(clusterName, openStackCluster)
441+
err = loadBalancerService.ReconcileLoadBalancer(openStackCluster, clusterName)
442442
if err != nil {
443443
return errors.Errorf("failed to reconcile load balancer: %v", err)
444444
}

controllers/openstackmachine_controller.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ func (r *OpenStackMachineReconciler) Reconcile(ctx context.Context, req ctrl.Req
139139

140140
// Handle deleted machines
141141
if !openStackMachine.DeletionTimestamp.IsZero() {
142-
return r.reconcileDelete(ctx, log, patchHelper, machine, openStackMachine, cluster, infraCluster)
142+
return r.reconcileDelete(ctx, log, patchHelper, cluster, infraCluster, machine, openStackMachine)
143143
}
144144

145145
// Handle non-deleted clusters
146-
return r.reconcileNormal(ctx, log, patchHelper, machine, openStackMachine, cluster, infraCluster)
146+
return r.reconcileNormal(ctx, log, patchHelper, cluster, infraCluster, machine, openStackMachine)
147147
}
148148

149149
func (r *OpenStackMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
@@ -183,7 +183,7 @@ func (r *OpenStackMachineReconciler) SetupWithManager(ctx context.Context, mgr c
183183
Complete(r)
184184
}
185185

186-
func (r *OpenStackMachineReconciler) reconcileDelete(ctx context.Context, logger logr.Logger, patchHelper *patch.Helper, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, cluster *clusterv1.Cluster, openStackCluster *infrav1.OpenStackCluster) (ctrl.Result, error) {
186+
func (r *OpenStackMachineReconciler) reconcileDelete(ctx context.Context, logger logr.Logger, patchHelper *patch.Helper, cluster *clusterv1.Cluster, openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine) (ctrl.Result, error) {
187187
logger.Info("Handling deleted OpenStackMachine")
188188

189189
clusterName := fmt.Sprintf("%s-%s", cluster.ObjectMeta.Namespace, cluster.Name)
@@ -208,7 +208,7 @@ func (r *OpenStackMachineReconciler) reconcileDelete(ctx context.Context, logger
208208
return ctrl.Result{}, err
209209
}
210210
if openStackCluster.Spec.ManagedAPIServerLoadBalancer {
211-
err = loadBalancerService.DeleteLoadBalancerMember(clusterName, machine, openStackMachine, openStackCluster)
211+
err = loadBalancerService.DeleteLoadBalancerMember(openStackCluster, machine, openStackMachine, clusterName)
212212
if err != nil {
213213
return ctrl.Result{}, err
214214
}
@@ -253,7 +253,7 @@ func (r *OpenStackMachineReconciler) reconcileDelete(ctx context.Context, logger
253253
return ctrl.Result{}, nil
254254
}
255255

256-
func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger logr.Logger, patchHelper *patch.Helper, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, cluster *clusterv1.Cluster, openStackCluster *infrav1.OpenStackCluster) (_ ctrl.Result, reterr error) {
256+
func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger logr.Logger, patchHelper *patch.Helper, cluster *clusterv1.Cluster, openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine) (_ ctrl.Result, reterr error) {
257257
// If the OpenStackMachine is in an error state, return early.
258258
if openStackMachine.Status.FailureReason != nil || openStackMachine.Status.FailureMessage != nil {
259259
logger.Info("Error state detected, skipping reconciliation")
@@ -300,7 +300,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
300300
return ctrl.Result{}, err
301301
}
302302

303-
instance, err := r.getOrCreate(computeService, machine, openStackMachine, cluster, openStackCluster, userData, logger)
303+
instance, err := r.getOrCreate(logger, cluster, openStackCluster, machine, openStackMachine, computeService, userData)
304304
if err != nil {
305305
handleUpdateMachineError(logger, openStackMachine, errors.Errorf("OpenStack instance cannot be created: %v", err))
306306
return ctrl.Result{}, err
@@ -343,7 +343,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
343343
}
344344

345345
if openStackCluster.Spec.ManagedAPIServerLoadBalancer {
346-
err = r.reconcileLoadBalancerMember(logger, osProviderClient, clientOpts, instance, clusterName, machine, openStackMachine, openStackCluster)
346+
err = r.reconcileLoadBalancerMember(logger, osProviderClient, clientOpts, openStackCluster, machine, openStackMachine, instance, clusterName)
347347
if err != nil {
348348
handleUpdateMachineError(logger, openStackMachine, errors.Errorf("LoadBalancerMember cannot be reconciled: %v", err))
349349
return ctrl.Result{}, nil
@@ -365,15 +365,15 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
365365
return ctrl.Result{}, nil
366366
}
367367

368-
func (r *OpenStackMachineReconciler) getOrCreate(computeService *compute.Service, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, cluster *clusterv1.Cluster, openStackCluster *infrav1.OpenStackCluster, userData string, logger logr.Logger) (*infrav1.Instance, error) {
368+
func (r *OpenStackMachineReconciler) getOrCreate(logger logr.Logger, cluster *clusterv1.Cluster, openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, computeService *compute.Service, userData string) (*infrav1.Instance, error) {
369369
instance, err := computeService.InstanceExists(openStackMachine.Name)
370370
if err != nil {
371371
return nil, err
372372
}
373373

374374
if instance == nil {
375375
logger.Info("Machine not exist, Creating Machine", "Machine", openStackMachine.Name)
376-
instance, err = computeService.InstanceCreate(cluster.Name, machine, openStackMachine, openStackCluster, userData)
376+
instance, err = computeService.InstanceCreate(openStackCluster, machine, openStackMachine, cluster.Name, userData)
377377
if err != nil {
378378
return nil, errors.Errorf("error creating Openstack instance: %v", err)
379379
}
@@ -390,14 +390,14 @@ func handleUpdateMachineError(logger logr.Logger, openstackMachine *infrav1.Open
390390
logger.Error(fmt.Errorf(string(err)), message.Error())
391391
}
392392

393-
func (r *OpenStackMachineReconciler) reconcileLoadBalancerMember(logger logr.Logger, osProviderClient *gophercloud.ProviderClient, clientOpts *clientconfig.ClientOpts, instance *infrav1.Instance, clusterName string, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, openStackCluster *infrav1.OpenStackCluster) error {
393+
func (r *OpenStackMachineReconciler) reconcileLoadBalancerMember(logger logr.Logger, osProviderClient *gophercloud.ProviderClient, clientOpts *clientconfig.ClientOpts, openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, instance *infrav1.Instance, clusterName string) error {
394394
ip := instance.IP
395395
loadbalancerService, err := loadbalancer.NewService(osProviderClient, clientOpts, logger)
396396
if err != nil {
397397
return err
398398
}
399399

400-
return loadbalancerService.ReconcileLoadBalancerMember(clusterName, machine, openStackMachine, openStackCluster, ip)
400+
return loadbalancerService.ReconcileLoadBalancerMember(openStackCluster, machine, openStackMachine, clusterName, ip)
401401
}
402402

403403
// OpenStackClusterToOpenStackMachine is a handler.ToRequestsFunc to be used to enqeue requests for reconciliation

pkg/cloud/services/compute/bastion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (s *Service) DeleteBastion(openStackCluster *infrav1.OpenStackCluster, serv
3939
return nil
4040
}
4141

42-
func (s *Service) CreateBastion(clusterName string, openStackCluster *infrav1.OpenStackCluster) (*infrav1.Instance, error) {
42+
func (s *Service) CreateBastion(openStackCluster *infrav1.OpenStackCluster, clusterName string) (*infrav1.Instance, error) {
4343
name := fmt.Sprintf("%s-bastion", clusterName)
4444
input := &infrav1.Instance{
4545
Name: name,

pkg/cloud/services/compute/instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const (
6363
)
6464

6565
// InstanceCreate creates a compute instance.
66-
func (s *Service) InstanceCreate(clusterName string, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, openStackCluster *infrav1.OpenStackCluster, userData string) (instance *infrav1.Instance, err error) {
66+
func (s *Service) InstanceCreate(openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, clusterName string, userData string) (instance *infrav1.Instance, err error) {
6767
if openStackMachine == nil {
6868
return nil, fmt.Errorf("create Options need be specified to create instace")
6969
}

pkg/cloud/services/loadbalancer/loadbalancer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const (
4040
kubeapiLBSuffix string = "kubeapi"
4141
)
4242

43-
func (s *Service) ReconcileLoadBalancer(clusterName string, openStackCluster *infrav1.OpenStackCluster) error {
43+
func (s *Service) ReconcileLoadBalancer(openStackCluster *infrav1.OpenStackCluster, clusterName string) error {
4444
loadBalancerName := getLoadBalancerName(clusterName)
4545
s.logger.Info("Reconciling loadbalancer", "name", loadBalancerName)
4646

@@ -166,7 +166,7 @@ func (s *Service) ReconcileLoadBalancer(clusterName string, openStackCluster *in
166166
return nil
167167
}
168168

169-
func (s *Service) ReconcileLoadBalancerMember(clusterName string, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, openStackCluster *infrav1.OpenStackCluster, ip string) error {
169+
func (s *Service) ReconcileLoadBalancerMember(openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, clusterName, ip string) error {
170170
if !util.IsControlPlaneMachine(machine) {
171171
return nil
172172
}
@@ -272,7 +272,7 @@ func (s *Service) DeleteLoadBalancer(loadBalancerName string) error {
272272
return nil
273273
}
274274

275-
func (s *Service) DeleteLoadBalancerMember(clusterName string, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, openStackCluster *infrav1.OpenStackCluster) error {
275+
func (s *Service) DeleteLoadBalancerMember(openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, clusterName string) error {
276276
if openStackMachine == nil || !util.IsControlPlaneMachine(machine) {
277277
return nil
278278
}

pkg/cloud/services/networking/network.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (s *Service) ReconcileExternalNetwork(openStackCluster *infrav1.OpenStackCl
9090
return errors.New("too many resources")
9191
}
9292

93-
func (s *Service) ReconcileNetwork(clusterName string, openStackCluster *infrav1.OpenStackCluster) error {
93+
func (s *Service) ReconcileNetwork(openStackCluster *infrav1.OpenStackCluster, clusterName string) error {
9494
networkName := fmt.Sprintf("%s-cluster-%s", networkPrefix, clusterName)
9595
s.logger.Info("Reconciling network", "name", networkName)
9696

@@ -164,7 +164,7 @@ func (s *Service) DeleteNetwork(network *infrav1.Network) error {
164164
return networks.Delete(s.client, network.ID).ExtractErr()
165165
}
166166

167-
func (s *Service) ReconcileSubnet(clusterName string, openStackCluster *infrav1.OpenStackCluster) error {
167+
func (s *Service) ReconcileSubnet(openStackCluster *infrav1.OpenStackCluster, clusterName string) error {
168168
if openStackCluster.Status.Network == nil || openStackCluster.Status.Network.ID == "" {
169169
s.logger.V(4).Info("No need to reconcile network components since no network exists.")
170170
return nil

pkg/cloud/services/networking/router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
3131
)
3232

33-
func (s *Service) ReconcileRouter(clusterName string, openStackCluster *infrav1.OpenStackCluster) error {
33+
func (s *Service) ReconcileRouter(openStackCluster *infrav1.OpenStackCluster, clusterName string) error {
3434
if openStackCluster.Status.Network == nil || openStackCluster.Status.Network.ID == "" {
3535
s.logger.V(3).Info("No need to reconcile router since no network exists.")
3636
return nil

pkg/cloud/services/networking/securitygroups.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var defaultRules = []infrav1.SecurityGroupRule{
5656
}
5757

5858
// Reconcile the security groups.
59-
func (s *Service) ReconcileSecurityGroups(clusterName string, openStackCluster *infrav1.OpenStackCluster) error {
59+
func (s *Service) ReconcileSecurityGroups(openStackCluster *infrav1.OpenStackCluster, clusterName string) error {
6060
s.logger.Info("Reconciling security groups", "cluster", clusterName)
6161
if !openStackCluster.Spec.ManagedSecurityGroups {
6262
s.logger.V(4).Info("No need to reconcile security groups", "cluster", clusterName)
@@ -82,7 +82,7 @@ func (s *Service) ReconcileSecurityGroups(clusterName string, openStackCluster *
8282
}
8383
}
8484
// create desired security groups
85-
desiredSecGroups, err := s.generateDesiredSecGroups(secGroupNames, openStackCluster)
85+
desiredSecGroups, err := s.generateDesiredSecGroups(openStackCluster, secGroupNames)
8686
if err != nil {
8787
return err
8888
}
@@ -114,7 +114,7 @@ func (s *Service) ReconcileSecurityGroups(clusterName string, openStackCluster *
114114
return nil
115115
}
116116

117-
func (s *Service) generateDesiredSecGroups(secGroupNames map[string]string, openStackCluster *infrav1.OpenStackCluster) (map[string]infrav1.SecurityGroup, error) {
117+
func (s *Service) generateDesiredSecGroups(openStackCluster *infrav1.OpenStackCluster, secGroupNames map[string]string) (map[string]infrav1.SecurityGroup, error) {
118118
desiredSecGroups := make(map[string]infrav1.SecurityGroup)
119119

120120
var secControlPlaneGroupID string

0 commit comments

Comments
 (0)