Skip to content

Commit 9b7d1ea

Browse files
committed
Address linter violations.
1 parent 409c7d1 commit 9b7d1ea

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

internal/controller/instance_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func (r *InstanceReconciler) Reconcile(ctx context.Context, req mcreconcile.Requ
7878
return ctrl.Result{}, nil
7979
}
8080

81+
pendingReason := "Pending"
8182
if condition := apimeta.FindStatusCondition(instance.Status.Conditions, computev1alpha.InstanceProgrammed); condition.Status != metav1.ConditionTrue {
8283
logger.Info("instance is not programmed", "instance", instance.Name)
8384
message := "Instance has not been programmed"
@@ -86,7 +87,7 @@ func (r *InstanceReconciler) Reconcile(ctx context.Context, req mcreconcile.Requ
8687
}
8788

8889
reason := computev1alpha.InstanceProgrammedReasonPendingProgramming
89-
if condition.Reason != "Pending" {
90+
if condition.Reason != pendingReason {
9091
reason = condition.Reason
9192
}
9293

@@ -114,8 +115,8 @@ func (r *InstanceReconciler) Reconcile(ctx context.Context, req mcreconcile.Requ
114115
message = condition.Message
115116
}
116117

117-
reason := "Pending"
118-
if condition.Reason != "Pending" {
118+
reason := pendingReason
119+
if condition.Reason != pendingReason {
119120
reason = condition.Reason
120121
}
121122

internal/controller/result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (r *Result) AddStatusUpdate(c client.Client, obj client.Object) {
5454
}
5555

5656
func (r Result) ShouldReturn() bool {
57-
return r.Err != nil || !r.Result.IsZero() || r.StopProcessing
57+
return r.Err != nil || !r.IsZero() || r.StopProcessing
5858
}
5959

6060
func (r Result) Complete(ctx context.Context) (ctrl.Result, error) {

internal/controller/workloaddeployment_controller.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ func (r *WorkloadDeploymentReconciler) Reconcile(ctx context.Context, req mcreco
124124

125125
result := r.reconcileNetworks(ctx, cl.GetClient(), &deployment)
126126
if result.ShouldReturn() {
127-
if result.Err == nil {
128-
// TODO(jreese) update instance status conditions to communicate what
129-
// we're waiting on.
130-
}
131-
132127
return result.Complete(ctx)
133128
}
134129

@@ -175,7 +170,7 @@ func (r *WorkloadDeploymentReconciler) Reconcile(ctx context.Context, req mcreco
175170
patchResult, err := controllerutil.CreateOrPatch(ctx, cl.GetClient(), &deployment, func() error {
176171
deployment.Status.Replicas = int32(replicas)
177172
deployment.Status.CurrentReplicas = int32(currentReplicas)
178-
deployment.Status.DesiredReplicas = int32(desiredReplicas)
173+
deployment.Status.DesiredReplicas = desiredReplicas
179174

180175
if readyReplicas > 0 {
181176
apimeta.SetStatusCondition(&deployment.Status.Conditions, metav1.Condition{
@@ -184,7 +179,6 @@ func (r *WorkloadDeploymentReconciler) Reconcile(ctx context.Context, req mcreco
184179
Reason: "StableInstanceFound",
185180
Message: fmt.Sprintf("%d/%d instances are ready", readyReplicas, replicas),
186181
})
187-
} else {
188182
}
189183

190184
return nil
@@ -484,7 +478,7 @@ func enqueueWorkloadDeploymentByLocation(ctx context.Context, mgr mcmanager.Mana
484478
return nil
485479
}
486480

487-
var requests []mcreconcile.Request
481+
requests := make([]mcreconcile.Request, 0, len(workloadDeployments.Items))
488482
for _, workload := range workloadDeployments.Items {
489483
requests = append(requests, mcreconcile.Request{
490484
Request: reconcile.Request{

0 commit comments

Comments
 (0)