2020-09-09 02:26:32 +00:00
|
|
|
package apiv1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
2020-09-11 02:09:46 +00:00
|
|
|
var (
|
|
|
|
registry = new(sync.Map)
|
|
|
|
)
|
2020-09-09 02:26:32 +00:00
|
|
|
|
|
|
|
// CertificateAuthorityServiceNewFunc is the type that represents the method to initialize a new
|
|
|
|
// CertificateAuthorityService.
|
|
|
|
type CertificateAuthorityServiceNewFunc func(ctx context.Context, opts Options) (CertificateAuthorityService, error)
|
|
|
|
|
|
|
|
// Register adds to the registry a method to create a KeyManager of type t.
|
|
|
|
func Register(t Type, fn CertificateAuthorityServiceNewFunc) {
|
2020-09-11 02:09:46 +00:00
|
|
|
registry.Store(t.String(), fn)
|
2020-09-09 02:26:32 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 14:49:39 +00:00
|
|
|
// LoadCertificateAuthorityServiceNewFunc returns the function to initialize a KeyManager.
|
2020-09-09 02:26:32 +00:00
|
|
|
func LoadCertificateAuthorityServiceNewFunc(t Type) (CertificateAuthorityServiceNewFunc, bool) {
|
2020-09-11 02:09:46 +00:00
|
|
|
v, ok := registry.Load(t.String())
|
2020-09-09 02:26:32 +00:00
|
|
|
if !ok {
|
|
|
|
return nil, false
|
|
|
|
}
|
|
|
|
fn, ok := v.(CertificateAuthorityServiceNewFunc)
|
|
|
|
return fn, ok
|
|
|
|
}
|