package util
import (
"fmt"
acmapi "gitbucket.jerxie.com/yangyangxie/AnthosCertManager/pkg/apis/anthoscertmanager/v1"
acmmeta "gitbucket.jerxie.com/yangyangxie/AnthosCertManager/pkg/apis/meta/v1"
)
const (
IssuerSelfSigned string = "selfsigned"
// IssuerCA is the name of the simple issuer
IssuerCA string = "ca"
)
// IssuerKind returns the kind of issuer for a certificate.
func IssuerKind(ref acmmeta.ObjectReference) string {
if ref.Kind == "" {
return acmapi.IssuerKind
}
return ref.Kind
}
// NameForIssuer determines the name of the Issuer implementation given an
// Issuer resource.
func NameForIssuer(i acmapi.GenericIssuer) (string, error) {
switch {
case i.GetSpec().CA != nil:
return IssuerCA, nil
case i.GetSpec().SelfSigned != nil:
return IssuerSelfSigned, nil
}
return "", fmt.Errorf("no issuer specified for Issuer '%s/%s'", i.GetObjectMeta().Namespace, i.GetObjectMeta().Name)
}