package cert
import (
"fmt"
"envoy-control-plane/internal/pkg/cert/api"
"envoy-control-plane/internal/pkg/cert/letsencrypt"
)
// NewCertIssuer is a factory function that creates a CertIssuer based on the provided type name.
// It allows the rest of the application to obtain an issuer without knowing the specific
// underlying implementation details.
func NewCertIssuer(issuerType string) (api.CertIssuer, error) {
switch issuerType {
case "letsencrypt":
// Return the concrete *letsencrypt.LetsEncryptIssuer, which satisfies the cert.CertIssuer interface.
return &letsencrypt.LetsEncryptIssuer{}, nil
// Add new certificate authority implementations here as new cases
// case "zerossl":
// return &zerossl.ZeroSSLIssuer{}, nil
default:
return nil, fmt.Errorf("unknown certificate issuer type: %s. Valid types: letsencrypt", issuerType)
}
}