Skip to content

Commit

Permalink
fix remaining bug
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon committed Jun 1, 2023
1 parent 9d7c07c commit 3530e09
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/controllers/certificaterequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ func (r *CertificateRequestReconciler) Reconcile(ctx context.Context, req ctrl.R
return ctrl.Result{}, nil
}

if r.CheckApprovedCondition {
// If CertificateRequest has not been approved, exit early.
if !cmutil.CertificateRequestIsApproved(&certificateRequest) {
log.Info("CertificateRequest has not been approved yet. Ignoring.")
return ctrl.Result{}, nil
}
}

// report gives feedback by updating the Ready Condition of the Certificate Request.
// For added visibility we also log a message and create a Kubernetes Event.
report := func(reason, message string, err error) {
Expand Down Expand Up @@ -162,18 +170,10 @@ func (r *CertificateRequestReconciler) Reconcile(ctx context.Context, req ctrl.R
}

message := "The CertificateRequest was denied by an approval controller"
setReadyCondition(cmmeta.ConditionFalse, cmapi.CertificateRequestReasonDenied, message)
report(cmapi.CertificateRequestReasonDenied, message, nil)
return ctrl.Result{}, nil
}

if r.CheckApprovedCondition {
// If CertificateRequest has not been approved, exit early.
if !cmutil.CertificateRequestIsApproved(&certificateRequest) {
log.Info("CertificateRequest has not been approved yet. Ignoring.")
return ctrl.Result{}, nil
}
}

// Add a Ready condition if one does not already exist
if ready := cmutil.GetCertificateRequestCondition(&certificateRequest, cmapi.CertificateRequestConditionReady); ready == nil {
report(cmapi.CertificateRequestReasonPending, "Initialising Ready condition", nil)
Expand Down

0 comments on commit 3530e09

Please sign in to comment.