forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck.go
43 lines (37 loc) · 991 Bytes
/
check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package pluginexternal
import (
"context"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
"github.com/grafana/grafana/pkg/setting"
)
type Service struct {
cfg *setting.Cfg
logger log.Logger
pluginStore pluginstore.Store
}
func ProvideService(
cfg *setting.Cfg, pluginStore pluginstore.Store,
) (*Service, error) {
logger := log.New("datasources")
s := &Service{
cfg: cfg,
logger: logger,
pluginStore: pluginStore,
}
return s, nil
}
func (s *Service) Run(ctx context.Context) error {
s.validateExternal()
return ctx.Err()
}
func (s *Service) validateExternal() {
for pluginID, pluginCfg := range s.cfg.PluginSettings {
if pluginCfg["as_external"] == "true" {
_, exists := s.pluginStore.Plugin(context.Background(), pluginID)
if !exists {
s.logger.Error("Core plugin expected to be loaded as external, but it is missing", "pluginID", pluginID)
}
}
}
}