Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcobebway committed Apr 12, 2024
1 parent ae48607 commit 6d2cead
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,15 @@ func (r *Reconciler) Reconcile(ctx context.Context, req kctrl.Request) (kctrl.Re
}

func (r *Reconciler) handleSubscriptionValidation(ctx context.Context, desiredSubscription *eventingv1alpha2.Subscription) error {
if validationErr := r.validateSubscriptionSpec(ctx, desiredSubscription); validationErr != nil {
var err error
if err = r.validateSubscriptionSpec(ctx, desiredSubscription); err != nil {
desiredSubscription.Status.SetNotReady()
desiredSubscription.Status.ClearTypes()
desiredSubscription.Status.ClearBackend()
desiredSubscription.Status.ClearConditions()
desiredSubscription.Status.SetSubscriptionSpecValidCondition(validationErr)
return reconcile.TerminalError(validationErr)
}

var noError error = nil
desiredSubscription.Status.SetSubscriptionSpecValidCondition(noError)
return noError
desiredSubscription.Status.SetSubscriptionSpecValidCondition(err)
return err
}

func (r *Reconciler) validateSubscriptionSpec(ctx context.Context, subscription *eventingv1alpha2.Subscription) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req kctrl.Request) (kctrl.Re
if updateErr := r.updateSubscriptionStatus(ctx, desiredSubscription, log); updateErr != nil {
return kctrl.Result{}, errors.Join(validationErr, updateErr)
}
return kctrl.Result{}, validationErr
return kctrl.Result{}, reconcile.TerminalError(validationErr)
}

// update the cleanEventTypes and config values in the subscription status, if changed
Expand Down Expand Up @@ -172,18 +172,15 @@ func (r *Reconciler) Reconcile(ctx context.Context, req kctrl.Request) (kctrl.Re
}

func (r *Reconciler) handleSubscriptionValidation(ctx context.Context, desiredSubscription *eventingv1alpha2.Subscription) error {
if validationErr := r.validateSubscriptionSpec(ctx, desiredSubscription); validationErr != nil {
var err error
if err = r.validateSubscriptionSpec(ctx, desiredSubscription); err != nil {
desiredSubscription.Status.SetNotReady()
desiredSubscription.Status.ClearTypes()
desiredSubscription.Status.ClearBackend()
desiredSubscription.Status.ClearConditions()
desiredSubscription.Status.SetSubscriptionSpecValidCondition(validationErr)
return reconcile.TerminalError(validationErr)
}

var noError error = nil
desiredSubscription.Status.SetSubscriptionSpecValidCondition(noError)
return noError
desiredSubscription.Status.SetSubscriptionSpecValidCondition(err)
return err
}

func (r *Reconciler) validateSubscriptionSpec(ctx context.Context, subscription *eventingv1alpha2.Subscription) error {
Expand Down

0 comments on commit 6d2cead

Please sign in to comment.