mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Ensure service registration occurs in right order (#74001)
* make sure service registration occurs in right order * fix test
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
41
pkg/plugins/manager/testdata/external-registration/plugin.json
vendored
Normal file
41
pkg/plugins/manager/testdata/external-registration/plugin.json
vendored
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user