Plugins: Expose ExternalService in request config (#85187)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/grafana/grafana-aws-sdk/pkg/awsds"
|
||||
"github.com/grafana/grafana-azure-sdk-go/v2/azsettings"
|
||||
"github.com/grafana/grafana/pkg/plugins/auth"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/proxy"
|
||||
@@ -18,7 +19,7 @@ import (
|
||||
var _ PluginRequestConfigProvider = (*RequestConfigProvider)(nil)
|
||||
|
||||
type PluginRequestConfigProvider interface {
|
||||
PluginRequestConfig(ctx context.Context, pluginID string) map[string]string
|
||||
PluginRequestConfig(ctx context.Context, pluginID string, externalService *auth.ExternalService) map[string]string
|
||||
}
|
||||
|
||||
type RequestConfigProvider struct {
|
||||
@@ -33,7 +34,7 @@ func NewRequestConfigProvider(cfg *PluginInstanceCfg) *RequestConfigProvider {
|
||||
|
||||
// PluginRequestConfig returns a map of configuration that should be passed in a plugin request.
|
||||
// nolint:gocyclo
|
||||
func (s *RequestConfigProvider) PluginRequestConfig(ctx context.Context, pluginID string) map[string]string {
|
||||
func (s *RequestConfigProvider) PluginRequestConfig(ctx context.Context, pluginID string, externalService *auth.ExternalService) map[string]string {
|
||||
m := make(map[string]string)
|
||||
|
||||
if s.cfg.GrafanaAppURL != "" {
|
||||
@@ -160,5 +161,9 @@ func (s *RequestConfigProvider) PluginRequestConfig(ctx context.Context, pluginI
|
||||
m[awsds.SigV4VerboseLoggingEnvVarKeyName] = strconv.FormatBool(s.cfg.SigV4VerboseLogging)
|
||||
}
|
||||
|
||||
if externalService != nil {
|
||||
m[backend.AppClientSecret] = externalService.ClientSecret
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user