Skip to content

Commit

Permalink
[certmanager] add GetIssuerByName()
Browse files Browse the repository at this point in the history
  • Loading branch information
stuggi committed Nov 8, 2023
1 parent 51d0ccf commit 4243298
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/certmanager/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)
Expand Down Expand Up @@ -146,3 +147,21 @@ func (i *Issuer) Delete(

return nil
}

// GetIssuerByName - get certmanager issuer by name
func GetIssuerByName(
ctx context.Context,
h *helper.Helper,
name string,
namespace string,
) (*certmgrv1.Issuer, error) {

issuer := &certmgrv1.Issuer{}

err := h.GetClient().Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, issuer)
if err != nil {
return nil, fmt.Errorf("Error getting issuer %s: %w", issuer.Name, err)
}

return issuer, nil
}

0 comments on commit 4243298

Please sign in to comment.