Plugins: Ensure service registration occurs in right order (#74001)

* make sure service registration occurs in right order

* fix test
This commit is contained in:
Will Browne
2023-08-29 14:55:08 +02:00
committed by GitHub
parent 9e1eab3d70
commit 557b1654f9
5 changed files with 208 additions and 6 deletions

View File

@@ -583,3 +583,26 @@ func (p *FakeBackendPlugin) Kill() {
defer p.mutex.Unlock()
p.Running = false
}
type FakeFeatureToggles struct {
features map[string]bool
}
func NewFakeFeatureToggles(features ...string) *FakeFeatureToggles {
m := make(map[string]bool)
for _, f := range features {
m[f] = true
}
return &FakeFeatureToggles{
features: m,
}
}
func (f *FakeFeatureToggles) GetEnabled(_ context.Context) map[string]bool {
return f.features
}
func (f *FakeFeatureToggles) IsEnabled(feature string) bool {
return f.features[feature]
}

View File

@@ -0,0 +1,41 @@
{
"id": "grafana-test-datasource",
"type": "datasource",
"name": "Test",
"backend": true,
"executable": "gpx_test_datasource",
"info": {
"author": {
"name": "Grafana Labs",
"url": "https://grafana.com"
},
"logos": {
"large": "img/ds.svg",
"small": "img/ds.svg"
},
"screenshots": [],
"updated": "2023-08-03",
"version": "1.0.0"
},
"externalServiceRegistration": {
"impersonation": {
"enabled" : true,
"groups" : true,
"permissions" : [
{
"action": "read",
"scope": "datasource"
}
]
},
"self": {
"enabled" : true,
"permissions" : [
{
"action": "read",
"scope": "datasource"
}
]
}
}
}

View File

@@ -131,6 +131,9 @@ func TestParsePluginTestdata(t *testing.T) {
rootid: "grafana-worldmap-panel",
subpath: "plugin",
},
"external-registration": {
rootid: "grafana-test-datasource",
},
}
staticRootPath, err := filepath.Abs("../manager/testdata")