Skip to content

Commit

Permalink
Remove lint ignore for gocritic
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDXY committed Oct 2, 2023
1 parent 3b7fbc6 commit 1add327
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions controllers/controllers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ var (

func TestMain(m *testing.M) {
setup()
defer teardown()
code := m.Run()
os.Exit(code) //nolint:gocritic
teardown()
os.Exit(code)
}

func setup() {
Expand Down
16 changes: 9 additions & 7 deletions controllers/vspheremachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,21 @@ func (r *machineReconciler) reconcileNormal(ctx context.Context, machineCtx capv
return reconcile.Result{}, nil
}

//nolint:gocritic
if r.supervisorBased {
err := r.setVMModifiers(ctx, machineCtx)
if err != nil {
return reconcile.Result{}, err
}
} else {
// Cluster `.status.infrastructureReady == false is handled differently depending on if the machine is supervisor based.
// 1) If the Cluster is not supervisor-based mark the VMProvisionedCondition false and return nil.
// 2) If the Cluster is supervisor-based continue to reconcile as InfrastructureReady is not set to true until after the kube apiserver is available.
if !r.supervisorBased {
// vmwarev1.VSphereCluster doesn't set Cluster.Status.Ready until the API endpoint is available.
if !machineCtx.GetCluster().Status.InfrastructureReady {
log.Info("Cluster infrastructure is not ready yet")
conditions.MarkFalse(machineCtx.GetVSphereMachine(), infrav1.VMProvisionedCondition, infrav1.WaitingForClusterInfrastructureReason, clusterv1.ConditionSeverityInfo, "")
return reconcile.Result{}, nil
}
} else {
err := r.setVMModifiers(ctx, machineCtx)
if err != nil {
return reconcile.Result{}, err
}

Check warning on line 308 in controllers/vspheremachine_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/vspheremachine_controller.go#L307-L308

Added lines #L307 - L308 were not covered by tests
}

// Make sure bootstrap data is available and populated.
Expand Down
14 changes: 3 additions & 11 deletions pkg/services/govmomi/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,17 +529,9 @@ func (vms *VMService) getMetadata(ctx *virtualMachineContext) (string, error) {

var metadataBase64 string
for _, ec := range obj.Config.ExtraConfig {
if optVal := ec.GetOptionValue(); optVal != nil {
// TODO(akutz) Using a switch instead of if in case we ever
// want to check the metadata encoding as well.
// Since the image stamped images always use
// base64, it should be okay to not check.
//nolint:gocritic
switch optVal.Key {
case guestInfoKeyMetadata:
if v, ok := optVal.Value.(string); ok {
metadataBase64 = v
}
if optVal := ec.GetOptionValue(); optVal != nil && optVal.Key == guestInfoKeyMetadata {
if v, ok := optVal.Value.(string); ok {
metadataBase64 = v

Check warning on line 534 in pkg/services/govmomi/service.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/govmomi/service.go#L532-L534

Added lines #L532 - L534 were not covered by tests
}
}
}
Expand Down

0 comments on commit 1add327

Please sign in to comment.