diff --git a/pkg/providers/all/all.go b/pkg/providers/all/all.go index 2d2371676bb7..de82b4bae1db 100644 --- a/pkg/providers/all/all.go +++ b/pkg/providers/all/all.go @@ -27,6 +27,7 @@ import ( // Alias these methods, so that folks can import this to get all providers. var ( - Enabled = providers.Enabled - Provide = providers.Provide + Enabled = providers.Enabled + Provide = providers.Provide + ProvideFrom = providers.ProvideFrom ) diff --git a/pkg/providers/interface.go b/pkg/providers/interface.go index 8ed4f1eaefe1..f89aa855da40 100644 --- a/pkg/providers/interface.go +++ b/pkg/providers/interface.go @@ -83,3 +83,15 @@ func Provide(ctx context.Context, audience string) (string, error) { } return id, err } + +// ProvideFrom fetches the specified provider +func ProvideFrom(ctx context.Context, provider string) (Interface, error) { + m.Lock() + defer m.Unlock() + + p, ok := providers[provider] + if !ok { + return nil, fmt.Errorf("%s is not a valid provider", provider) + } + return p, nil +}