mirror of
https://github.com/grafana/grafana.git
synced 2026-06-10 09:01:30 -04:00
Plugin Proxy: Narrow data source config to DataSourceProxySettings The data source proxy only needs a handful of fields from setting.Cfg. Introduce a focused DataSourceProxySettings struct that exposes only those fields, load Azure settings lazily via a resolver callback so the proxy avoids touching Azure configuration unless an Azure-authenticated route is matched, and pass the new struct through the datasource proxy service in place of *setting.Cfg.
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package pluginproxy
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana-azure-sdk-go/v2/azsettings"
|
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
type DataSourceProxySettings struct {
|
|
SendUserHeader bool
|
|
DataProxyUserAgent string
|
|
DataProxyForwardUserAgent bool
|
|
LoginCookieName string
|
|
DataProxyLogging bool
|
|
DataProxyWhiteList map[string]bool
|
|
|
|
// Load azure settings (avoid fetching the settings unless we are running azure)
|
|
GetAzureSettings func(context.Context) (*azsettings.AzureSettings, error)
|
|
}
|
|
|
|
func NewDataSourceProxySettings(cfg *setting.Cfg) *DataSourceProxySettings {
|
|
return &DataSourceProxySettings{
|
|
SendUserHeader: cfg.SendUserHeader,
|
|
DataProxyUserAgent: cfg.DataProxyUserAgent,
|
|
DataProxyForwardUserAgent: cfg.DataProxyForwardUserAgent,
|
|
LoginCookieName: cfg.LoginCookieName,
|
|
DataProxyLogging: cfg.DataProxyLogging,
|
|
DataProxyWhiteList: cfg.DataProxyWhiteList,
|
|
|
|
GetAzureSettings: func(context.Context) (*azsettings.AzureSettings, error) {
|
|
return cfg.Azure, nil
|
|
},
|
|
}
|
|
}
|