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:
@@ -27,8 +27,6 @@ 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"
|
||||
)
|
||||
|
||||
@@ -56,29 +54,18 @@ const defaultRegion = "default"
|
||||
const logIdentifierInternal = "__log__grafana_internal__"
|
||||
const logStreamIdentifierInternal = "__logstream__grafana_internal__"
|
||||
|
||||
const pluginID = "cloudwatch"
|
||||
|
||||
var plog = log.New("tsdb.cloudwatch")
|
||||
var aliasFormat = regexp.MustCompile(`\{\{\s*(.+?)\s*\}\}`)
|
||||
|
||||
func ProvideService(cfg *setting.Cfg, httpClientProvider httpclient.Provider, pluginStore plugins.Store) (*CloudWatchService, error) {
|
||||
func ProvideService(cfg *setting.Cfg, httpClientProvider httpclient.Provider) *CloudWatchService {
|
||||
plog.Debug("initing")
|
||||
|
||||
executor := newExecutor(datasource.NewInstanceManager(NewInstanceSettings(httpClientProvider)), cfg, awsds.NewSessionCache())
|
||||
factory := coreplugin.New(backend.ServeOpts{
|
||||
QueryDataHandler: executor,
|
||||
})
|
||||
|
||||
resolver := plugins.CoreDataSourcePathResolver(cfg, pluginID)
|
||||
if err := pluginStore.AddWithFactory(context.Background(), pluginID, factory, resolver); err != nil {
|
||||
plog.Error("Failed to register plugin", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &CloudWatchService{
|
||||
Cfg: cfg,
|
||||
Executor: executor,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
type CloudWatchService struct {
|
||||
|
||||
Reference in New Issue
Block a user