Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
validate the presence of specified cluster or clusterisssuer in tlspo…
Browse files Browse the repository at this point in the history
…licy
  • Loading branch information
laurafitzgerald committed Sep 21, 2023
1 parent 59f52d3 commit 2382665
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/controllers/tlspolicy/tlspolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package tlspolicy
import (
"context"
"fmt"
v1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"

"github.com/go-logr/logr"

Expand Down Expand Up @@ -151,6 +152,24 @@ func (r *TLSPolicyReconciler) reconcileResources(ctx context.Context, tlsPolicy
return err
}

// validate that the issuer specified exists
issuerName := tlsPolicy.Spec.IssuerRef.Name
issuerKind := tlsPolicy.Spec.IssuerRef.Kind
if issuerKind == v1.ClusterIssuerKind {
issuer := &v1.ClusterIssuer{}
err = r.Client().Get(ctx, client.ObjectKey{Name: issuerName}, issuer)
if err != nil {
return err
}
}
if issuerKind == v1.IssuerKind {
issuer := &v1.Issuer{}
err = r.Client().Get(ctx, client.ObjectKey{Name: issuerName, Namespace: tlsPolicy.Namespace}, issuer)
if err != nil {
return err
}
}

// reconcile based on gateway diffs
gatewayDiffObj, err := r.ComputeGatewayDiffs(ctx, tlsPolicy, targetNetworkObject, &TLSPolicyRefsConfig{})
if err != nil {
Expand Down

0 comments on commit 2382665

Please sign in to comment.