Plugins: Core plugins register via backend factory provider (#43171)

* refactoring store interface and init flow

* fix import

* fix linter

* refactor resource calling

* load with class

* re-order args

* fix tests

* fix linter

* remove old creator

* add custom config struct

* fix some tests

* cleanup

* fix

* tackle plugins

* fix linter

* refactor and fix test

* add connect failure error

* add fix for azure, cloud monitoring and test data

* restructure

* remove unused err

* add fake tracer for test

* fix grafana ds plugin
This commit is contained in:
Will Browne
2022-01-20 18:16:22 +01:00
committed by GitHub
parent 2fd76ecaf7
commit 7fbc7d019a
30 changed files with 326 additions and 380 deletions
+3 -18
View File
@@ -19,35 +19,20 @@ import (
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/infra/httpclient"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
"github.com/grafana/grafana/pkg/setting"
"golang.org/x/net/context/ctxhttp"
)
const pluginID = "opentsdb"
type Service struct {
logger log.Logger
im instancemgmt.InstanceManager
}
func ProvideService(cfg *setting.Cfg, httpClientProvider httpclient.Provider, pluginStore plugins.Store) (*Service, error) {
im := datasource.NewInstanceManager(newInstanceSettings(httpClientProvider))
s := &Service{
func ProvideService(httpClientProvider httpclient.Provider) *Service {
return &Service{
logger: log.New("tsdb.opentsdb"),
im: im,
im: datasource.NewInstanceManager(newInstanceSettings(httpClientProvider)),
}
factory := coreplugin.New(backend.ServeOpts{
QueryDataHandler: s,
})
resolver := plugins.CoreDataSourcePathResolver(cfg, pluginID)
if err := pluginStore.AddWithFactory(context.Background(), pluginID, factory, resolver); err != nil {
return nil, err
}
return s, nil
}
type datasourceInfo struct {