Plugins: Refactor plugin config into separate env var and request scoped services (#83261)
* seperate services for env + req * merge with main * fix tests * undo changes to golden file * fix linter * remove unused fields * split out new config struct * provide config * undo go mod changes * more renaming * fix tests * undo bra.toml changes * update go.work.sum * undo changes * trigger * apply PR feedback
This commit is contained in:
@@ -18,10 +18,10 @@ import (
|
||||
// on the plugins CDN, and it will switch to the correct implementation depending on the plugin and the config.
|
||||
type Service struct {
|
||||
cdn *pluginscdn.Service
|
||||
cfg *config.Cfg
|
||||
cfg *config.PluginManagementCfg
|
||||
}
|
||||
|
||||
func ProvideService(cfg *config.Cfg, cdn *pluginscdn.Service) *Service {
|
||||
func ProvideService(cfg *config.PluginManagementCfg, cdn *pluginscdn.Service) *Service {
|
||||
return &Service{cfg: cfg, cdn: cdn}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func NewPluginInfo(pluginJSON plugins.JSONData, class plugins.Class, fs plugins.
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultService(cfg *config.Cfg) *Service {
|
||||
func DefaultService(cfg *config.PluginManagementCfg) *Service {
|
||||
return &Service{cfg: cfg, cdn: pluginscdn.ProvideService(cfg)}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestService(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
cfg := &config.Cfg{
|
||||
cfg := &config.PluginManagementCfg{
|
||||
PluginsCDNURLTemplate: tc.cdnBaseURL,
|
||||
PluginSettings: map[string]map[string]string{
|
||||
"one": {"cdn": "true"},
|
||||
@@ -142,7 +142,7 @@ func TestService(t *testing.T) {
|
||||
appSubURL: "/grafana/",
|
||||
},
|
||||
} {
|
||||
cfg := &config.Cfg{GrafanaAppSubURL: tc.appSubURL}
|
||||
cfg := &config.PluginManagementCfg{GrafanaAppSubURL: tc.appSubURL}
|
||||
svc := ProvideService(cfg, pluginscdn.ProvideService(cfg))
|
||||
|
||||
dir := "/plugins/test-datasource"
|
||||
|
||||
Reference in New Issue
Block a user