Reduce nesting on loop
@@ -127,7 +127,10 @@ func (r *ReconcileTrial) Reconcile(request reconcile.Request) (reconcile.Result,
// Apply the patches
for i := range trial.Spec.PatchOperations {
p := &trial.Spec.PatchOperations[i]
- if p.AttemptsRemaining > 0 {
+ if p.AttemptsRemaining == 0 {
+ continue
+ }
+
u := unstructured.Unstructured{}
u.SetName(p.TargetRef.Name)
u.SetNamespace(p.TargetRef.Namespace)
@@ -151,7 +154,6 @@ func (r *ReconcileTrial) Reconcile(request reconcile.Request) (reconcile.Result,
err = r.Update(context.TODO(), trial)
return reconcile.Result{}, err
}
- }
// If there is a patched condition that is not yet true, update the status
if cc, ok := checkCondition(&trial.Status, redskyv1alpha1.TrialPatched, corev1.ConditionTrue); ok && !cc {
