func (resolver *Resolver) Provider(name string) (provider plugin_v1.Provider, err error) {
	mutex := &sync.Mutex{}
	mutex.Lock()
	defer mutex.Unlock()
	if provider = resolver.Providers[name]; provider != nil {
		return
	}
	if _, ok := resolver.ProviderFactories[name]; !ok {
		resolver.LogFatalf("ERROR: Provider '%s' cannot be found", name)
	}
	providerOptions := plugin_v1.ProviderOptions{
		Name: name,
	}
	providerFactory := resolver.ProviderFactories[name]
	log.Printf("Instantiating provider '%s'", name)
	provider, err = providerFactory(providerOptions)
	if err != nil {
		return nil, err
	}
	resolver.Providers[name] = provider
	return
}
Provider finds or creates a named provider.
package plugin
import (
	"fmt"
	"log"
	"sort"
	"strings"
	"sync"
	plugin_v1 "github.com/cyberark/secretless-broker/internal/plugin/v1"
	config_v2 "github.com/cyberark/secretless-broker/pkg/secretless/config/v2"
)
type Resolver struct {
	EventNotifier     plugin_v1.EventNotifier
	ProviderFactories map[string]func(plugin_v1.ProviderOptions) (plugin_v1.Provider, error)
	Providers         map[string]plugin_v1.Provider
	LogFatalf         func(string, ...interface{})
}
func NewResolver(
	providerFactories map[string]func(plugin_v1.ProviderOptions) (plugin_v1.Provider, error),
	eventNotifier plugin_v1.EventNotifier,
	LogFatalFunc func(string, ...interface{}),
) plugin_v1.Resolver {
	if LogFatalFunc == nil {
		LogFatalFunc = log.Fatalf
	}
	return &Resolver{
		EventNotifier:     eventNotifier,
		LogFatalf:         LogFatalFunc,
		ProviderFactories: providerFactories,
		Providers:         make(map[string]plugin_v1.Provider),
	}
}