mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Move store and plugin dto to pluginsintegration (#74655)
move store and plugin dto
This commit is contained in:
parent
499b02b3c6
commit
e855efb13d
@ -7,14 +7,14 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/api/response"
|
"github.com/grafana/grafana/pkg/api/response"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/services/alerting"
|
"github.com/grafana/grafana/pkg/services/alerting"
|
||||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ToDashboardErrorResponse returns a different response status according to the dashboard error type
|
// ToDashboardErrorResponse returns a different response status according to the dashboard error type
|
||||||
func ToDashboardErrorResponse(ctx context.Context, pluginStore plugins.Store, err error) response.Response {
|
func ToDashboardErrorResponse(ctx context.Context, pluginStore pluginstore.Store, err error) response.Response {
|
||||||
var dashboardErr dashboards.DashboardErr
|
var dashboardErr dashboards.DashboardErr
|
||||||
if ok := errors.As(err, &dashboardErr); ok {
|
if ok := errors.As(err, &dashboardErr); ok {
|
||||||
if body := dashboardErr.Body(); body != nil {
|
if body := dashboardErr.Body(); body != nil {
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/infra/usagestats"
|
"github.com/grafana/grafana/pkg/infra/usagestats"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/registry/corekind"
|
"github.com/grafana/grafana/pkg/registry/corekind"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||||
@ -49,6 +48,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/librarypanels"
|
"github.com/grafana/grafana/pkg/services/librarypanels"
|
||||||
"github.com/grafana/grafana/pkg/services/live"
|
"github.com/grafana/grafana/pkg/services/live"
|
||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
pref "github.com/grafana/grafana/pkg/services/preference"
|
pref "github.com/grafana/grafana/pkg/services/preference"
|
||||||
"github.com/grafana/grafana/pkg/services/preference/preftest"
|
"github.com/grafana/grafana/pkg/services/preference/preftest"
|
||||||
"github.com/grafana/grafana/pkg/services/provisioning"
|
"github.com/grafana/grafana/pkg/services/provisioning"
|
||||||
@ -76,7 +76,7 @@ func TestGetHomeDashboard(t *testing.T) {
|
|||||||
|
|
||||||
hs := &HTTPServer{
|
hs := &HTTPServer{
|
||||||
Cfg: cfg,
|
Cfg: cfg,
|
||||||
pluginStore: &fakes.FakePluginStore{},
|
pluginStore: &pluginstore.FakePluginStore{},
|
||||||
SQLStore: dbtest.NewFakeDB(),
|
SQLStore: dbtest.NewFakeDB(),
|
||||||
preferenceService: prefService,
|
preferenceService: prefService,
|
||||||
dashboardVersionService: dashboardVersionService,
|
dashboardVersionService: dashboardVersionService,
|
||||||
@ -782,7 +782,7 @@ func TestDashboardVersionsAPIEndpoint(t *testing.T) {
|
|||||||
getHS := func(userSvc *usertest.FakeUserService) *HTTPServer {
|
getHS := func(userSvc *usertest.FakeUserService) *HTTPServer {
|
||||||
return &HTTPServer{
|
return &HTTPServer{
|
||||||
Cfg: cfg,
|
Cfg: cfg,
|
||||||
pluginStore: &fakes.FakePluginStore{},
|
pluginStore: &pluginstore.FakePluginStore{},
|
||||||
SQLStore: mockSQLStore,
|
SQLStore: mockSQLStore,
|
||||||
AccessControl: accesscontrolmock.New(),
|
AccessControl: accesscontrolmock.New(),
|
||||||
Features: featuremgmt.WithFeatures(),
|
Features: featuremgmt.WithFeatures(),
|
||||||
@ -976,7 +976,7 @@ func postDashboardScenario(t *testing.T, desc string, url string, routePattern s
|
|||||||
ProvisioningService: provisioning.NewProvisioningServiceMock(context.Background()),
|
ProvisioningService: provisioning.NewProvisioningServiceMock(context.Background()),
|
||||||
Live: newTestLive(t, db.InitTestDB(t)),
|
Live: newTestLive(t, db.InitTestDB(t)),
|
||||||
QuotaService: quotatest.New(false, nil),
|
QuotaService: quotatest.New(false, nil),
|
||||||
pluginStore: &fakes.FakePluginStore{},
|
pluginStore: &pluginstore.FakePluginStore{},
|
||||||
LibraryPanelService: &mockLibraryPanelService{},
|
LibraryPanelService: &mockLibraryPanelService{},
|
||||||
LibraryElementService: &mockLibraryElementService{},
|
LibraryElementService: &mockLibraryElementService{},
|
||||||
DashboardService: dashboardService,
|
DashboardService: dashboardService,
|
||||||
|
@ -15,13 +15,13 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/api/routing"
|
"github.com/grafana/grafana/pkg/api/routing"
|
||||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||||
"github.com/grafana/grafana/pkg/infra/db/dbtest"
|
"github.com/grafana/grafana/pkg/infra/db/dbtest"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
|
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
|
||||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources/guardian"
|
"github.com/grafana/grafana/pkg/services/datasources/guardian"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/web"
|
"github.com/grafana/grafana/pkg/web"
|
||||||
"github.com/grafana/grafana/pkg/web/webtest"
|
"github.com/grafana/grafana/pkg/web/webtest"
|
||||||
@ -47,7 +47,7 @@ func TestDataSourcesProxy_userLoggedIn(t *testing.T) {
|
|||||||
// handler func being tested
|
// handler func being tested
|
||||||
hs := &HTTPServer{
|
hs := &HTTPServer{
|
||||||
Cfg: setting.NewCfg(),
|
Cfg: setting.NewCfg(),
|
||||||
pluginStore: &fakes.FakePluginStore{},
|
pluginStore: &pluginstore.FakePluginStore{},
|
||||||
DataSourcesService: &dataSourcesServiceMock{
|
DataSourcesService: &dataSourcesServiceMock{
|
||||||
expectedDatasources: ds,
|
expectedDatasources: ds,
|
||||||
},
|
},
|
||||||
@ -71,7 +71,7 @@ func TestDataSourcesProxy_userLoggedIn(t *testing.T) {
|
|||||||
// handler func being tested
|
// handler func being tested
|
||||||
hs := &HTTPServer{
|
hs := &HTTPServer{
|
||||||
Cfg: setting.NewCfg(),
|
Cfg: setting.NewCfg(),
|
||||||
pluginStore: &fakes.FakePluginStore{},
|
pluginStore: &pluginstore.FakePluginStore{},
|
||||||
}
|
}
|
||||||
sc.handlerFunc = hs.DeleteDataSourceByName
|
sc.handlerFunc = hs.DeleteDataSourceByName
|
||||||
sc.fakeReqWithParams("DELETE", sc.url, map[string]string{}).exec()
|
sc.fakeReqWithParams("DELETE", sc.url, map[string]string{}).exec()
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/licensing"
|
"github.com/grafana/grafana/pkg/services/licensing"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
"github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
||||||
@ -426,7 +427,7 @@ func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, availablePlug
|
|||||||
return dataSources, nil
|
return dataSources, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAppDTO(plugin plugins.PluginDTO, settings pluginsettings.InfoDTO) *plugins.AppDTO {
|
func newAppDTO(plugin pluginstore.Plugin, settings pluginsettings.InfoDTO) *plugins.AppDTO {
|
||||||
app := &plugins.AppDTO{
|
app := &plugins.AppDTO{
|
||||||
ID: plugin.ID,
|
ID: plugin.ID,
|
||||||
Version: plugin.Info.Version,
|
Version: plugin.Info.Version,
|
||||||
@ -484,7 +485,7 @@ func getPanelSort(id string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type availablePluginDTO struct {
|
type availablePluginDTO struct {
|
||||||
Plugin plugins.PluginDTO
|
Plugin pluginstore.Plugin
|
||||||
Settings pluginsettings.InfoDTO
|
Settings pluginsettings.InfoDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/login/social"
|
"github.com/grafana/grafana/pkg/login/social"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/config"
|
"github.com/grafana/grafana/pkg/plugins/config"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
||||||
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/licensing"
|
"github.com/grafana/grafana/pkg/services/licensing"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/rendering"
|
"github.com/grafana/grafana/pkg/services/rendering"
|
||||||
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlestest"
|
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlestest"
|
||||||
"github.com/grafana/grafana/pkg/services/updatechecker"
|
"github.com/grafana/grafana/pkg/services/updatechecker"
|
||||||
@ -30,7 +30,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/web"
|
"github.com/grafana/grafana/pkg/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupTestEnvironment(t *testing.T, cfg *setting.Cfg, features *featuremgmt.FeatureManager, pstore plugins.Store, psettings pluginsettings.Service) (*web.Mux, *HTTPServer) {
|
func setupTestEnvironment(t *testing.T, cfg *setting.Cfg, features *featuremgmt.FeatureManager, pstore pluginstore.Store, psettings pluginsettings.Service) (*web.Mux, *HTTPServer) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
db.InitTestDB(t)
|
db.InitTestDB(t)
|
||||||
cfg.IsFeatureToggleEnabled = features.IsEnabled
|
cfg.IsFeatureToggleEnabled = features.IsEnabled
|
||||||
@ -48,7 +48,7 @@ func setupTestEnvironment(t *testing.T, cfg *setting.Cfg, features *featuremgmt.
|
|||||||
|
|
||||||
var pluginStore = pstore
|
var pluginStore = pstore
|
||||||
if pluginStore == nil {
|
if pluginStore == nil {
|
||||||
pluginStore = &fakes.FakePluginStore{}
|
pluginStore = &pluginstore.FakePluginStore{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var pluginsSettings = psettings
|
var pluginsSettings = psettings
|
||||||
@ -212,15 +212,15 @@ func TestHTTPServer_GetFrontendSettings_apps(t *testing.T) {
|
|||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
desc string
|
desc string
|
||||||
pluginStore func() plugins.Store
|
pluginStore func() pluginstore.Store
|
||||||
pluginSettings func() pluginsettings.Service
|
pluginSettings func() pluginsettings.Service
|
||||||
expected settings
|
expected settings
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "disabled app with preload",
|
desc: "disabled app with preload",
|
||||||
pluginStore: func() plugins.Store {
|
pluginStore: func() pluginstore.Store {
|
||||||
return &fakes.FakePluginStore{
|
return &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
Module: fmt.Sprintf("/%s/module.js", "test-app"),
|
Module: fmt.Sprintf("/%s/module.js", "test-app"),
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
@ -251,9 +251,9 @@ func TestHTTPServer_GetFrontendSettings_apps(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "enabled app with preload",
|
desc: "enabled app with preload",
|
||||||
pluginStore: func() plugins.Store {
|
pluginStore: func() pluginstore.Store {
|
||||||
return &fakes.FakePluginStore{
|
return &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
Module: fmt.Sprintf("/%s/module.js", "test-app"),
|
Module: fmt.Sprintf("/%s/module.js", "test-app"),
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
@ -284,9 +284,9 @@ func TestHTTPServer_GetFrontendSettings_apps(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "angular app plugin",
|
desc: "angular app plugin",
|
||||||
pluginStore: func() plugins.Store {
|
pluginStore: func() pluginstore.Store {
|
||||||
return &fakes.FakePluginStore{
|
return &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
Module: fmt.Sprintf("/%s/module.js", "test-app"),
|
Module: fmt.Sprintf("/%s/module.js", "test-app"),
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
|
@ -70,6 +70,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
pref "github.com/grafana/grafana/pkg/services/preference"
|
pref "github.com/grafana/grafana/pkg/services/preference"
|
||||||
"github.com/grafana/grafana/pkg/services/provisioning"
|
"github.com/grafana/grafana/pkg/services/provisioning"
|
||||||
publicdashboardsApi "github.com/grafana/grafana/pkg/services/publicdashboards/api"
|
publicdashboardsApi "github.com/grafana/grafana/pkg/services/publicdashboards/api"
|
||||||
@ -130,7 +131,7 @@ type HTTPServer struct {
|
|||||||
DataProxy *datasourceproxy.DataSourceProxyService
|
DataProxy *datasourceproxy.DataSourceProxyService
|
||||||
PluginRequestValidator validations.PluginRequestValidator
|
PluginRequestValidator validations.PluginRequestValidator
|
||||||
pluginClient plugins.Client
|
pluginClient plugins.Client
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
pluginInstaller plugins.Installer
|
pluginInstaller plugins.Installer
|
||||||
pluginFileStore plugins.FileStore
|
pluginFileStore plugins.FileStore
|
||||||
pluginDashboardService plugindashboards.Service
|
pluginDashboardService plugindashboards.Service
|
||||||
@ -215,7 +216,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
|
|||||||
renderService rendering.Service, licensing licensing.Licensing, hooksService *hooks.HooksService,
|
renderService rendering.Service, licensing licensing.Licensing, hooksService *hooks.HooksService,
|
||||||
cacheService *localcache.CacheService, sqlStore *sqlstore.SQLStore, alertEngine *alerting.AlertEngine,
|
cacheService *localcache.CacheService, sqlStore *sqlstore.SQLStore, alertEngine *alerting.AlertEngine,
|
||||||
pluginRequestValidator validations.PluginRequestValidator, pluginStaticRouteResolver plugins.StaticRouteResolver,
|
pluginRequestValidator validations.PluginRequestValidator, pluginStaticRouteResolver plugins.StaticRouteResolver,
|
||||||
pluginDashboardService plugindashboards.Service, pluginStore plugins.Store, pluginClient plugins.Client,
|
pluginDashboardService plugindashboards.Service, pluginStore pluginstore.Store, pluginClient plugins.Client,
|
||||||
pluginErrorResolver plugins.ErrorResolver, pluginInstaller plugins.Installer, settingsProvider setting.Provider,
|
pluginErrorResolver plugins.ErrorResolver, pluginInstaller plugins.Installer, settingsProvider setting.Provider,
|
||||||
dataSourceCache datasources.CacheService, userTokenService auth.UserTokenService,
|
dataSourceCache datasources.CacheService, userTokenService auth.UserTokenService,
|
||||||
cleanUpService *cleanup.CleanUpService, shortURLService shorturls.Service, queryHistoryService queryhistory.Service,
|
cleanUpService *cleanup.CleanUpService, shortURLService shorturls.Service, queryHistoryService queryhistory.Service,
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
||||||
"github.com/grafana/grafana/pkg/plugins/config"
|
"github.com/grafana/grafana/pkg/plugins/config"
|
||||||
pluginClient "github.com/grafana/grafana/pkg/plugins/manager/client"
|
pluginClient "github.com/grafana/grafana/pkg/plugins/manager/client"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
fakeDatasources "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
fakeDatasources "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
||||||
@ -28,6 +27,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/query"
|
"github.com/grafana/grafana/pkg/services/query"
|
||||||
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
||||||
secretstest "github.com/grafana/grafana/pkg/services/secrets/fakes"
|
secretstest "github.com/grafana/grafana/pkg/services/secrets/fakes"
|
||||||
@ -67,8 +67,8 @@ func TestAPIEndpoint_Metrics_QueryMetricsV2(t *testing.T) {
|
|||||||
return &backend.QueryDataResponse{Responses: resp}, nil
|
return &backend.QueryDataResponse{Responses: resp}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugincontext.ProvideService(localcache.ProvideService(), &fakes.FakePluginStore{
|
plugincontext.ProvideService(localcache.ProvideService(), &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "grafana",
|
ID: "grafana",
|
||||||
@ -113,8 +113,8 @@ func TestAPIEndpoint_Metrics_PluginDecryptionFailure(t *testing.T) {
|
|||||||
ds := &fakeDatasources.FakeDataSourceService{SimulatePluginFailure: true}
|
ds := &fakeDatasources.FakeDataSourceService{SimulatePluginFailure: true}
|
||||||
db := &dbtest.FakeDB{ExpectedError: pluginsettings.ErrPluginSettingNotFound}
|
db := &dbtest.FakeDB{ExpectedError: pluginsettings.ErrPluginSettingNotFound}
|
||||||
pcp := plugincontext.ProvideService(localcache.ProvideService(),
|
pcp := plugincontext.ProvideService(localcache.ProvideService(),
|
||||||
&fakes.FakePluginStore{
|
&pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "grafana",
|
ID: "grafana",
|
||||||
@ -294,8 +294,8 @@ func TestDataSourceQueryError(t *testing.T) {
|
|||||||
nil,
|
nil,
|
||||||
&fakePluginRequestValidator{},
|
&fakePluginRequestValidator{},
|
||||||
pluginClient.ProvideService(r, &config.Cfg{}),
|
pluginClient.ProvideService(r, &config.Cfg{}),
|
||||||
plugincontext.ProvideService(localcache.ProvideService(), &fakes.FakePluginStore{
|
plugincontext.ProvideService(localcache.ProvideService(), &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{p.ToDTO()},
|
PluginList: []pluginstore.Plugin{pluginstore.ToGrafanaDTO(p)},
|
||||||
},
|
},
|
||||||
ds, pluginSettings.ProvideService(dbtest.NewFakeDB(),
|
ds, pluginSettings.ProvideService(dbtest.NewFakeDB(),
|
||||||
secretstest.NewFakeSecretsService()),
|
secretstest.NewFakeSecretsService()),
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
"github.com/grafana/grafana/pkg/web"
|
"github.com/grafana/grafana/pkg/web"
|
||||||
@ -72,7 +73,7 @@ func (hs *HTTPServer) GetPluginList(c *contextmodel.ReqContext) response.Respons
|
|||||||
|
|
||||||
// Filter plugins
|
// Filter plugins
|
||||||
pluginDefinitions := hs.pluginStore.Plugins(c.Req.Context())
|
pluginDefinitions := hs.pluginStore.Plugins(c.Req.Context())
|
||||||
filteredPluginDefinitions := []plugins.PluginDTO{}
|
filteredPluginDefinitions := []pluginstore.Plugin{}
|
||||||
filteredPluginIDs := map[string]bool{}
|
filteredPluginIDs := map[string]bool{}
|
||||||
for _, pluginDef := range pluginDefinitions {
|
for _, pluginDef := range pluginDefinitions {
|
||||||
// filter out app sub plugins
|
// filter out app sub plugins
|
||||||
@ -347,7 +348,7 @@ func (hs *HTTPServer) getPluginAssets(c *contextmodel.ReqContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// serveLocalPluginAsset returns the content of a plugin asset file from the local filesystem to the http client.
|
// serveLocalPluginAsset returns the content of a plugin asset file from the local filesystem to the http client.
|
||||||
func (hs *HTTPServer) serveLocalPluginAsset(c *contextmodel.ReqContext, plugin plugins.PluginDTO, assetPath string) {
|
func (hs *HTTPServer) serveLocalPluginAsset(c *contextmodel.ReqContext, plugin pluginstore.Plugin, assetPath string) {
|
||||||
f, err := hs.pluginFileStore.File(c.Req.Context(), plugin.ID, assetPath)
|
f, err := hs.pluginFileStore.File(c.Req.Context(), plugin.ID, assetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, plugins.ErrFileNotExist) {
|
if errors.Is(err, plugins.ErrFileNotExist) {
|
||||||
@ -368,7 +369,7 @@ func (hs *HTTPServer) serveLocalPluginAsset(c *contextmodel.ReqContext, plugin p
|
|||||||
}
|
}
|
||||||
|
|
||||||
// redirectCDNPluginAsset redirects the http request to specified asset path on the configured plugins CDN.
|
// redirectCDNPluginAsset redirects the http request to specified asset path on the configured plugins CDN.
|
||||||
func (hs *HTTPServer) redirectCDNPluginAsset(c *contextmodel.ReqContext, plugin plugins.PluginDTO, assetPath string) {
|
func (hs *HTTPServer) redirectCDNPluginAsset(c *contextmodel.ReqContext, plugin pluginstore.Plugin, assetPath string) {
|
||||||
remoteURL, err := hs.pluginsCDNService.AssetURL(plugin.ID, plugin.Info.Version, assetPath)
|
remoteURL, err := hs.pluginsCDNService.AssetURL(plugin.ID, plugin.Info.Version, assetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JsonApiErr(500, "Failed to get CDN plugin asset remote URL", err)
|
c.JsonApiErr(500, "Failed to get CDN plugin asset remote URL", err)
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/filestore"
|
"github.com/grafana/grafana/pkg/plugins/manager/filestore"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/store"
|
|
||||||
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
||||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||||
@ -34,6 +33,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/org/orgtest"
|
"github.com/grafana/grafana/pkg/services/org/orgtest"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/updatechecker"
|
"github.com/grafana/grafana/pkg/services/updatechecker"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/web/webtest"
|
"github.com/grafana/grafana/pkg/web/webtest"
|
||||||
@ -485,7 +485,7 @@ func pluginAssetScenario(t *testing.T, desc string, url string, urlPattern strin
|
|||||||
cfg.IsFeatureToggleEnabled = func(_ string) bool { return false }
|
cfg.IsFeatureToggleEnabled = func(_ string) bool { return false }
|
||||||
hs := HTTPServer{
|
hs := HTTPServer{
|
||||||
Cfg: cfg,
|
Cfg: cfg,
|
||||||
pluginStore: store.New(pluginRegistry, &fakes.FakeLoader{}),
|
pluginStore: pluginstore.New(pluginRegistry, &fakes.FakeLoader{}),
|
||||||
pluginFileStore: filestore.ProvideService(pluginRegistry),
|
pluginFileStore: filestore.ProvideService(pluginRegistry),
|
||||||
log: log.NewNopLogger(),
|
log: log.NewNopLogger(),
|
||||||
pluginsCDNService: pluginscdn.ProvideService(&config.Cfg{
|
pluginsCDNService: pluginscdn.ProvideService(&config.Cfg{
|
||||||
@ -597,7 +597,7 @@ func Test_PluginsList_AccessControl(t *testing.T) {
|
|||||||
server := SetupAPITestServer(t, func(hs *HTTPServer) {
|
server := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||||
hs.Cfg = setting.NewCfg()
|
hs.Cfg = setting.NewCfg()
|
||||||
hs.PluginSettings = &pluginSettings
|
hs.PluginSettings = &pluginSettings
|
||||||
hs.pluginStore = store.New(pluginRegistry, &fakes.FakeLoader{})
|
hs.pluginStore = pluginstore.New(pluginRegistry, &fakes.FakeLoader{})
|
||||||
hs.pluginFileStore = filestore.ProvideService(pluginRegistry)
|
hs.pluginFileStore = filestore.ProvideService(pluginRegistry)
|
||||||
var err error
|
var err error
|
||||||
hs.pluginsUpdateChecker, err = updatechecker.ProvidePluginsService(hs.Cfg, nil, tracing.InitializeTracerForTest())
|
hs.pluginsUpdateChecker, err = updatechecker.ProvidePluginsService(hs.Cfg, nil, tracing.InitializeTracerForTest())
|
||||||
|
@ -11,11 +11,11 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
datafakes "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
datafakes "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/user"
|
"github.com/grafana/grafana/pkg/services/user"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
@ -53,8 +53,8 @@ func framesPassThroughService(t *testing.T, frames data.Frames) (data.Frames, er
|
|||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
dataService: me,
|
dataService: me,
|
||||||
features: &featuremgmt.FeatureManager{},
|
features: &featuremgmt.FeatureManager{},
|
||||||
pCtxProvider: plugincontext.ProvideService(nil, &fakes.FakePluginStore{
|
pCtxProvider: plugincontext.ProvideService(nil, &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{JSONData: plugins.JSONData{ID: "test"}},
|
{JSONData: plugins.JSONData{ID: "test"}},
|
||||||
}},
|
}},
|
||||||
&datafakes.FakeDataSourceService{}, nil),
|
&datafakes.FakeDataSourceService{}, nil),
|
||||||
|
@ -14,11 +14,11 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
datafakes "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
datafakes "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/user"
|
"github.com/grafana/grafana/pkg/services/user"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
@ -32,8 +32,8 @@ func TestService(t *testing.T) {
|
|||||||
Frames: []*data.Frame{dsDF},
|
Frames: []*data.Frame{dsDF},
|
||||||
}
|
}
|
||||||
|
|
||||||
pCtxProvider := plugincontext.ProvideService(nil, &fakes.FakePluginStore{
|
pCtxProvider := plugincontext.ProvideService(nil, &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{JSONData: plugins.JSONData{ID: "test"}},
|
{JSONData: plugins.JSONData{ID: "test"}},
|
||||||
},
|
},
|
||||||
}, &datafakes.FakeDataSourceService{}, nil)
|
}, &datafakes.FakeDataSourceService{}, nil)
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/registry"
|
"github.com/grafana/grafana/pkg/registry"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/stats"
|
"github.com/grafana/grafana/pkg/services/stats"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
@ -31,7 +32,7 @@ const (
|
|||||||
type Service struct {
|
type Service struct {
|
||||||
cfg *setting.Cfg
|
cfg *setting.Cfg
|
||||||
sqlstore db.DB
|
sqlstore db.DB
|
||||||
plugins plugins.Store
|
plugins pluginstore.Store
|
||||||
usageStats usagestats.Service
|
usageStats usagestats.Service
|
||||||
validator validator.Service
|
validator validator.Service
|
||||||
statsService stats.Service
|
statsService stats.Service
|
||||||
@ -54,7 +55,7 @@ func ProvideService(
|
|||||||
cfg *setting.Cfg,
|
cfg *setting.Cfg,
|
||||||
store db.DB,
|
store db.DB,
|
||||||
social social.Service,
|
social social.Service,
|
||||||
plugins plugins.Store,
|
plugins pluginstore.Store,
|
||||||
features *featuremgmt.FeatureManager,
|
features *featuremgmt.FeatureManager,
|
||||||
datasourceService datasources.DataSourceService,
|
datasourceService datasources.DataSourceService,
|
||||||
httpClientProvider httpclient.Provider,
|
httpClientProvider httpclient.Provider,
|
||||||
|
@ -20,10 +20,10 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/usagestats/validator"
|
"github.com/grafana/grafana/pkg/infra/usagestats/validator"
|
||||||
"github.com/grafana/grafana/pkg/login/social"
|
"github.com/grafana/grafana/pkg/login/social"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/registry"
|
"github.com/grafana/grafana/pkg/registry"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/stats"
|
"github.com/grafana/grafana/pkg/services/stats"
|
||||||
"github.com/grafana/grafana/pkg/services/stats/statstest"
|
"github.com/grafana/grafana/pkg/services/stats/statstest"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
@ -355,8 +355,8 @@ func (m *mockSocial) GetOAuthProviders() map[string]bool {
|
|||||||
func setupSomeDataSourcePlugins(t *testing.T, s *Service) {
|
func setupSomeDataSourcePlugins(t *testing.T, s *Service) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
s.plugins = &fakes.FakePluginStore{
|
s.plugins = &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{JSONData: plugins.JSONData{ID: datasources.DS_ES}, Signature: "internal"},
|
{JSONData: plugins.JSONData{ID: datasources.DS_ES}, Signature: "internal"},
|
||||||
{JSONData: plugins.JSONData{ID: datasources.DS_PROMETHEUS}, Signature: "internal"},
|
{JSONData: plugins.JSONData{ID: datasources.DS_PROMETHEUS}, Signature: "internal"},
|
||||||
{JSONData: plugins.JSONData{ID: datasources.DS_GRAPHITE}, Signature: "internal"},
|
{JSONData: plugins.JSONData{ID: datasources.DS_GRAPHITE}, Signature: "internal"},
|
||||||
@ -381,7 +381,7 @@ func createService(t testing.TB, cfg *setting.Cfg, store db.DB, statsService sta
|
|||||||
cfg,
|
cfg,
|
||||||
store,
|
store,
|
||||||
&mockSocial{},
|
&mockSocial{},
|
||||||
&fakes.FakePluginStore{},
|
&pluginstore.FakePluginStore{},
|
||||||
featuremgmt.WithFeatures("feature1", "feature2"),
|
featuremgmt.WithFeatures("feature1", "feature2"),
|
||||||
o.datasources,
|
o.datasources,
|
||||||
httpclient.NewProvider(),
|
httpclient.NewProvider(),
|
||||||
|
@ -3,14 +3,14 @@ package validator
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UsageStatsValidator struct {
|
type UsageStatsValidator struct {
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideService(pluginStore plugins.Store) (Service, error) {
|
func ProvideService(pluginStore pluginstore.Store) (Service, error) {
|
||||||
s := &UsageStatsValidator{
|
s := &UsageStatsValidator{
|
||||||
pluginStore: pluginStore,
|
pluginStore: pluginStore,
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Store is the publicly accessible storage for plugins.
|
|
||||||
type Store interface {
|
|
||||||
// Plugin finds a plugin by its ID.
|
|
||||||
Plugin(ctx context.Context, pluginID string) (PluginDTO, bool)
|
|
||||||
// Plugins returns plugins by their requested type.
|
|
||||||
Plugins(ctx context.Context, pluginTypes ...Type) []PluginDTO
|
|
||||||
}
|
|
||||||
|
|
||||||
type Installer interface {
|
type Installer interface {
|
||||||
// Add adds a new plugin.
|
// Add adds a new plugin.
|
||||||
Add(ctx context.Context, pluginID, version string, opts CompatOpts) error
|
Add(ctx context.Context, pluginID, version string, opts CompatOpts) error
|
||||||
|
@ -433,37 +433,6 @@ func (f *FakeOauthService) RegisterExternalService(ctx context.Context, name str
|
|||||||
return f.Result, nil
|
return f.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type FakePluginStore struct {
|
|
||||||
PluginList []plugins.PluginDTO
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pr *FakePluginStore) Plugin(_ context.Context, pluginID string) (plugins.PluginDTO, bool) {
|
|
||||||
for _, v := range pr.PluginList {
|
|
||||||
if v.ID == pluginID {
|
|
||||||
return v, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return plugins.PluginDTO{}, false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pr *FakePluginStore) Plugins(_ context.Context, pluginTypes ...plugins.Type) []plugins.PluginDTO {
|
|
||||||
var result []plugins.PluginDTO
|
|
||||||
if len(pluginTypes) == 0 {
|
|
||||||
pluginTypes = plugins.PluginTypes
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range pr.PluginList {
|
|
||||||
for _, t := range pluginTypes {
|
|
||||||
if v.Type == t {
|
|
||||||
result = append(result, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
type FakeDiscoverer struct {
|
type FakeDiscoverer struct {
|
||||||
DiscoverFunc func(ctx context.Context, src plugins.PluginSource) ([]*plugins.FoundBundle, error)
|
DiscoverFunc func(ctx context.Context, src plugins.PluginSource) ([]*plugins.FoundBundle, error)
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,6 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/config"
|
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,10 +22,6 @@ func TestFinder_Find(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := setting.NewCfg()
|
|
||||||
pCfg, err := config.ProvideConfig(setting.ProvideProvider(cfg), cfg, featuremgmt.WithFeatures())
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
pluginDirs []string
|
pluginDirs []string
|
||||||
@ -255,7 +248,7 @@ func TestFinder_Find(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
f := NewLocalFinder(pCfg.DevMode)
|
f := NewLocalFinder(false)
|
||||||
pluginBundles, err := f.Find(context.Background(), &fakes.FakePluginSource{
|
pluginBundles, err := f.Find(context.Background(), &fakes.FakePluginSource{
|
||||||
PluginURIsFunc: func(ctx context.Context) []string {
|
PluginURIsFunc: func(ctx context.Context) []string {
|
||||||
return tc.pluginDirs
|
return tc.pluginDirs
|
||||||
@ -279,10 +272,6 @@ func TestFinder_Find(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
|
func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
|
||||||
cfg := setting.NewCfg()
|
|
||||||
pCfg, err := config.ProvideConfig(setting.ProvideProvider(cfg), cfg, featuremgmt.WithFeatures())
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
t.Run("When scanning a folder that doesn't exists shouldn't return an error", func(t *testing.T) {
|
t.Run("When scanning a folder that doesn't exists shouldn't return an error", func(t *testing.T) {
|
||||||
origWalk := walk
|
origWalk := walk
|
||||||
walk = func(path string, followSymlinks, detectSymlinkInfiniteLoop bool, walkFn util.WalkFunc) error {
|
walk = func(path string, followSymlinks, detectSymlinkInfiniteLoop bool, walkFn util.WalkFunc) error {
|
||||||
@ -292,7 +281,7 @@ func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
|
|||||||
walk = origWalk
|
walk = origWalk
|
||||||
})
|
})
|
||||||
|
|
||||||
finder := NewLocalFinder(pCfg.DevMode)
|
finder := NewLocalFinder(false)
|
||||||
paths, err := finder.getAbsPluginJSONPaths("test")
|
paths, err := finder.getAbsPluginJSONPaths("test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Empty(t, paths)
|
require.Empty(t, paths)
|
||||||
@ -307,7 +296,7 @@ func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
|
|||||||
walk = origWalk
|
walk = origWalk
|
||||||
})
|
})
|
||||||
|
|
||||||
finder := NewLocalFinder(pCfg.DevMode)
|
finder := NewLocalFinder(false)
|
||||||
paths, err := finder.getAbsPluginJSONPaths("test")
|
paths, err := finder.getAbsPluginJSONPaths("test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Empty(t, paths)
|
require.Empty(t, paths)
|
||||||
@ -322,7 +311,7 @@ func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
|
|||||||
walk = origWalk
|
walk = origWalk
|
||||||
})
|
})
|
||||||
|
|
||||||
finder := NewLocalFinder(pCfg.DevMode)
|
finder := NewLocalFinder(false)
|
||||||
paths, err := finder.getAbsPluginJSONPaths("test")
|
paths, err := finder.getAbsPluginJSONPaths("test")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Empty(t, paths)
|
require.Empty(t, paths)
|
||||||
|
@ -69,52 +69,6 @@ type Plugin struct {
|
|||||||
Alias string `json:"alias,omitempty"`
|
Alias string `json:"alias,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PluginDTO struct {
|
|
||||||
JSONData
|
|
||||||
|
|
||||||
fs FS
|
|
||||||
logger log.Logger
|
|
||||||
supportsStreaming bool
|
|
||||||
|
|
||||||
Class Class
|
|
||||||
|
|
||||||
// App fields
|
|
||||||
IncludedInAppID string
|
|
||||||
DefaultNavURL string
|
|
||||||
Pinned bool
|
|
||||||
|
|
||||||
// Signature fields
|
|
||||||
Signature SignatureStatus
|
|
||||||
SignatureType SignatureType
|
|
||||||
SignatureOrg string
|
|
||||||
SignatureError *SignatureError
|
|
||||||
|
|
||||||
// SystemJS fields
|
|
||||||
Module string
|
|
||||||
BaseURL string
|
|
||||||
|
|
||||||
AngularDetected bool
|
|
||||||
|
|
||||||
// This will be moved to plugin.json when we have general support in gcom
|
|
||||||
Alias string `json:"alias,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p PluginDTO) SupportsStreaming() bool {
|
|
||||||
return p.supportsStreaming
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p PluginDTO) Base() string {
|
|
||||||
return p.fs.Base()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p PluginDTO) IsApp() bool {
|
|
||||||
return p.Type == TypeApp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p PluginDTO) IsCorePlugin() bool {
|
|
||||||
return p.Class == ClassCore
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSONData represents the plugin's plugin.json
|
// JSONData represents the plugin's plugin.json
|
||||||
type JSONData struct {
|
type JSONData struct {
|
||||||
// Common settings
|
// Common settings
|
||||||
@ -446,27 +400,6 @@ type PluginClient interface {
|
|||||||
backend.StreamHandler
|
backend.StreamHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugin) ToDTO() PluginDTO {
|
|
||||||
return PluginDTO{
|
|
||||||
logger: p.Logger(),
|
|
||||||
fs: p.FS,
|
|
||||||
supportsStreaming: p.client != nil && p.client.(backend.StreamHandler) != nil,
|
|
||||||
Class: p.Class,
|
|
||||||
JSONData: p.JSONData,
|
|
||||||
IncludedInAppID: p.IncludedInAppID,
|
|
||||||
DefaultNavURL: p.DefaultNavURL,
|
|
||||||
Pinned: p.Pinned,
|
|
||||||
Signature: p.Signature,
|
|
||||||
SignatureType: p.SignatureType,
|
|
||||||
SignatureOrg: p.SignatureOrg,
|
|
||||||
SignatureError: p.SignatureError,
|
|
||||||
Module: p.Module,
|
|
||||||
BaseURL: p.BaseURL,
|
|
||||||
AngularDetected: p.AngularDetected,
|
|
||||||
Alias: p.Alias,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Plugin) StaticRoute() *StaticRoute {
|
func (p *Plugin) StaticRoute() *StaticRoute {
|
||||||
if p.IsCorePlugin() {
|
if p.IsCorePlugin() {
|
||||||
return nil
|
return nil
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
uss "github.com/grafana/grafana/pkg/infra/usagestats/service"
|
uss "github.com/grafana/grafana/pkg/infra/usagestats/service"
|
||||||
"github.com/grafana/grafana/pkg/infra/usagestats/statscollector"
|
"github.com/grafana/grafana/pkg/infra/usagestats/statscollector"
|
||||||
pluginStore "github.com/grafana/grafana/pkg/plugins/manager/store"
|
|
||||||
"github.com/grafana/grafana/pkg/registry"
|
"github.com/grafana/grafana/pkg/registry"
|
||||||
"github.com/grafana/grafana/pkg/services/alerting"
|
"github.com/grafana/grafana/pkg/services/alerting"
|
||||||
"github.com/grafana/grafana/pkg/services/auth"
|
"github.com/grafana/grafana/pkg/services/auth"
|
||||||
@ -25,6 +24,7 @@ import (
|
|||||||
plugindashboardsservice "github.com/grafana/grafana/pkg/services/plugindashboards/service"
|
plugindashboardsservice "github.com/grafana/grafana/pkg/services/plugindashboards/service"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/angulardetectorsprovider"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/angulardetectorsprovider"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/keyretriever/dynamic"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/keyretriever/dynamic"
|
||||||
|
pluginStore "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/provisioning"
|
"github.com/grafana/grafana/pkg/services/provisioning"
|
||||||
publicdashboardsmetric "github.com/grafana/grafana/pkg/services/publicdashboards/metric"
|
publicdashboardsmetric "github.com/grafana/grafana/pkg/services/publicdashboards/metric"
|
||||||
"github.com/grafana/grafana/pkg/services/rendering"
|
"github.com/grafana/grafana/pkg/services/rendering"
|
||||||
|
@ -32,7 +32,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/login/social"
|
"github.com/grafana/grafana/pkg/login/social"
|
||||||
"github.com/grafana/grafana/pkg/middleware/csrf"
|
"github.com/grafana/grafana/pkg/middleware/csrf"
|
||||||
"github.com/grafana/grafana/pkg/middleware/loggermw"
|
"github.com/grafana/grafana/pkg/middleware/loggermw"
|
||||||
pluginDashboards "github.com/grafana/grafana/pkg/plugins/manager/dashboards"
|
|
||||||
"github.com/grafana/grafana/pkg/registry/corekind"
|
"github.com/grafana/grafana/pkg/registry/corekind"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||||
@ -93,6 +92,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||||
plugindashboardsservice "github.com/grafana/grafana/pkg/services/plugindashboards/service"
|
plugindashboardsservice "github.com/grafana/grafana/pkg/services/plugindashboards/service"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration"
|
||||||
|
pluginDashboards "github.com/grafana/grafana/pkg/services/pluginsintegration/dashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/preference/prefimpl"
|
"github.com/grafana/grafana/pkg/services/preference/prefimpl"
|
||||||
"github.com/grafana/grafana/pkg/services/publicdashboards"
|
"github.com/grafana/grafana/pkg/services/publicdashboards"
|
||||||
publicdashboardsApi "github.com/grafana/grafana/pkg/services/publicdashboards/api"
|
publicdashboardsApi "github.com/grafana/grafana/pkg/services/publicdashboards/api"
|
||||||
|
@ -7,11 +7,11 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/api/response"
|
"github.com/grafana/grafana/pkg/api/response"
|
||||||
"github.com/grafana/grafana/pkg/api/routing"
|
"github.com/grafana/grafana/pkg/api/routing"
|
||||||
"github.com/grafana/grafana/pkg/middleware"
|
"github.com/grafana/grafana/pkg/middleware"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||||
"github.com/grafana/grafana/pkg/services/dashboardimport"
|
"github.com/grafana/grafana/pkg/services/dashboardimport"
|
||||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/quota"
|
"github.com/grafana/grafana/pkg/services/quota"
|
||||||
"github.com/grafana/grafana/pkg/web"
|
"github.com/grafana/grafana/pkg/web"
|
||||||
)
|
)
|
||||||
@ -19,12 +19,12 @@ import (
|
|||||||
type ImportDashboardAPI struct {
|
type ImportDashboardAPI struct {
|
||||||
dashboardImportService dashboardimport.Service
|
dashboardImportService dashboardimport.Service
|
||||||
quotaService QuotaService
|
quotaService QuotaService
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
ac accesscontrol.AccessControl
|
ac accesscontrol.AccessControl
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(dashboardImportService dashboardimport.Service, quotaService QuotaService,
|
func New(dashboardImportService dashboardimport.Service, quotaService QuotaService,
|
||||||
pluginStore plugins.Store, ac accesscontrol.AccessControl) *ImportDashboardAPI {
|
pluginStore pluginstore.Store, ac accesscontrol.AccessControl) *ImportDashboardAPI {
|
||||||
return &ImportDashboardAPI{
|
return &ImportDashboardAPI{
|
||||||
dashboardImportService: dashboardImportService,
|
dashboardImportService: dashboardImportService,
|
||||||
quotaService: quotaService,
|
quotaService: quotaService,
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/api/routing"
|
"github.com/grafana/grafana/pkg/api/routing"
|
||||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||||
"github.com/grafana/grafana/pkg/services/dashboardimport"
|
"github.com/grafana/grafana/pkg/services/dashboardimport"
|
||||||
@ -15,12 +14,13 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/folder"
|
"github.com/grafana/grafana/pkg/services/folder"
|
||||||
"github.com/grafana/grafana/pkg/services/librarypanels"
|
"github.com/grafana/grafana/pkg/services/librarypanels"
|
||||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/quota"
|
"github.com/grafana/grafana/pkg/services/quota"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ProvideService(routeRegister routing.RouteRegister,
|
func ProvideService(routeRegister routing.RouteRegister,
|
||||||
quotaService quota.Service,
|
quotaService quota.Service,
|
||||||
pluginDashboardService plugindashboards.Service, pluginStore plugins.Store,
|
pluginDashboardService plugindashboards.Service, pluginStore pluginstore.Store,
|
||||||
libraryPanelService librarypanels.Service, dashboardService dashboards.DashboardService,
|
libraryPanelService librarypanels.Service, dashboardService dashboards.DashboardService,
|
||||||
ac accesscontrol.AccessControl, folderService folder.Service,
|
ac accesscontrol.AccessControl, folderService folder.Service,
|
||||||
) *ImportDashboardService {
|
) *ImportDashboardService {
|
||||||
|
@ -12,10 +12,10 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/httpclient"
|
"github.com/grafana/grafana/pkg/infra/httpclient"
|
||||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
"github.com/grafana/grafana/pkg/services/oauthtoken"
|
"github.com/grafana/grafana/pkg/services/oauthtoken"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/secrets"
|
"github.com/grafana/grafana/pkg/services/secrets"
|
||||||
"github.com/grafana/grafana/pkg/services/validations"
|
"github.com/grafana/grafana/pkg/services/validations"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
@ -24,7 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func ProvideService(dataSourceCache datasources.CacheService, plugReqValidator validations.PluginRequestValidator,
|
func ProvideService(dataSourceCache datasources.CacheService, plugReqValidator validations.PluginRequestValidator,
|
||||||
pluginStore plugins.Store, cfg *setting.Cfg, httpClientProvider httpclient.Provider,
|
pluginStore pluginstore.Store, cfg *setting.Cfg, httpClientProvider httpclient.Provider,
|
||||||
oauthTokenService *oauthtoken.Service, dsService datasources.DataSourceService,
|
oauthTokenService *oauthtoken.Service, dsService datasources.DataSourceService,
|
||||||
tracer tracing.Tracer, secretsService secrets.Service) *DataSourceProxyService {
|
tracer tracing.Tracer, secretsService secrets.Service) *DataSourceProxyService {
|
||||||
return &DataSourceProxyService{
|
return &DataSourceProxyService{
|
||||||
@ -43,7 +43,7 @@ func ProvideService(dataSourceCache datasources.CacheService, plugReqValidator v
|
|||||||
type DataSourceProxyService struct {
|
type DataSourceProxyService struct {
|
||||||
DataSourceCache datasources.CacheService
|
DataSourceCache datasources.CacheService
|
||||||
PluginRequestValidator validations.PluginRequestValidator
|
PluginRequestValidator validations.PluginRequestValidator
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
Cfg *setting.Cfg
|
Cfg *setting.Cfg
|
||||||
HTTPClientProvider httpclient.Provider
|
HTTPClientProvider httpclient.Provider
|
||||||
OAuthTokenService *oauthtoken.Service
|
OAuthTokenService *oauthtoken.Service
|
||||||
|
@ -11,9 +11,9 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/web"
|
"github.com/grafana/grafana/pkg/web"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -88,7 +88,7 @@ func TestDatasourceProxy_proxyDatasourceRequest(t *testing.T) {
|
|||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
pluginID := datasources.DS_PROMETHEUS
|
pluginID := datasources.DS_PROMETHEUS
|
||||||
|
|
||||||
pluginStore := &fakes.FakePluginStore{PluginList: []plugins.PluginDTO{
|
pluginStore := &pluginstore.FakePluginStore{PluginList: []pluginstore.Plugin{
|
||||||
{JSONData: plugins.JSONData{ID: pluginID}},
|
{JSONData: plugins.JSONData{ID: pluginID}},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/live/survey"
|
"github.com/grafana/grafana/pkg/services/live/survey"
|
||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/query"
|
"github.com/grafana/grafana/pkg/services/query"
|
||||||
"github.com/grafana/grafana/pkg/services/secrets"
|
"github.com/grafana/grafana/pkg/services/secrets"
|
||||||
"github.com/grafana/grafana/pkg/services/user"
|
"github.com/grafana/grafana/pkg/services/user"
|
||||||
@ -73,7 +74,7 @@ type CoreGrafanaScope struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ProvideService(plugCtxProvider *plugincontext.Provider, cfg *setting.Cfg, routeRegister routing.RouteRegister,
|
func ProvideService(plugCtxProvider *plugincontext.Provider, cfg *setting.Cfg, routeRegister routing.RouteRegister,
|
||||||
pluginStore plugins.Store, pluginClient plugins.Client, cacheService *localcache.CacheService,
|
pluginStore pluginstore.Store, pluginClient plugins.Client, cacheService *localcache.CacheService,
|
||||||
dataSourceCache datasources.CacheService, sqlStore db.DB, secretsService secrets.Service,
|
dataSourceCache datasources.CacheService, sqlStore db.DB, secretsService secrets.Service,
|
||||||
usageStatsService usagestats.Service, queryDataService query.Service, toggles featuremgmt.FeatureToggles,
|
usageStatsService usagestats.Service, queryDataService query.Service, toggles featuremgmt.FeatureToggles,
|
||||||
accessControl accesscontrol.AccessControl, dashboardService dashboards.DashboardService, annotationsRepo annotations.Repository,
|
accessControl accesscontrol.AccessControl, dashboardService dashboards.DashboardService, annotationsRepo annotations.Repository,
|
||||||
@ -356,7 +357,7 @@ type GrafanaLive struct {
|
|||||||
DataSourceCache datasources.CacheService
|
DataSourceCache datasources.CacheService
|
||||||
SQLStore db.DB
|
SQLStore db.DB
|
||||||
SecretsService secrets.Service
|
SecretsService secrets.Service
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
pluginClient plugins.Client
|
pluginClient plugins.Client
|
||||||
queryDataService query.Service
|
queryDataService query.Service
|
||||||
orgService org.Service
|
orgService org.Service
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/navtree"
|
"github.com/grafana/grafana/pkg/services/navtree"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ func (s *ServiceImpl) addAppLinks(treeRoot *navtree.NavTreeRoot, c *contextmodel
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
isPluginEnabled := func(plugin plugins.PluginDTO) bool {
|
isPluginEnabled := func(plugin pluginstore.Plugin) bool {
|
||||||
if plugin.AutoEnabled {
|
if plugin.AutoEnabled {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ func (s *ServiceImpl) addAppLinks(treeRoot *navtree.NavTreeRoot, c *contextmodel
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceImpl) processAppPlugin(plugin plugins.PluginDTO, c *contextmodel.ReqContext, treeRoot *navtree.NavTreeRoot) *navtree.NavLink {
|
func (s *ServiceImpl) processAppPlugin(plugin pluginstore.Plugin, c *contextmodel.ReqContext, treeRoot *navtree.NavTreeRoot) *navtree.NavLink {
|
||||||
hasAccessToInclude := s.hasAccessToInclude(c, plugin.ID)
|
hasAccessToInclude := s.hasAccessToInclude(c, plugin.ID)
|
||||||
appLink := &navtree.NavLink{
|
appLink := &navtree.NavLink{
|
||||||
Text: plugin.Name,
|
Text: plugin.Name,
|
||||||
@ -165,7 +166,7 @@ func (s *ServiceImpl) processAppPlugin(plugin plugins.PluginDTO, c *contextmodel
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceImpl) addPluginToSection(c *contextmodel.ReqContext, treeRoot *navtree.NavTreeRoot, plugin plugins.PluginDTO, appLink *navtree.NavLink) {
|
func (s *ServiceImpl) addPluginToSection(c *contextmodel.ReqContext, treeRoot *navtree.NavTreeRoot, plugin pluginstore.Plugin, appLink *navtree.NavLink) {
|
||||||
// Handle moving apps into specific navtree sections
|
// Handle moving apps into specific navtree sections
|
||||||
alertingNode := treeRoot.FindById(navtree.NavIDAlerting)
|
alertingNode := treeRoot.FindById(navtree.NavIDAlerting)
|
||||||
if alertingNode == nil {
|
if alertingNode == nil {
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/models/roletype"
|
"github.com/grafana/grafana/pkg/models/roletype"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||||
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||||
@ -19,6 +18,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/navtree"
|
"github.com/grafana/grafana/pkg/services/navtree"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/user"
|
"github.com/grafana/grafana/pkg/services/user"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/web"
|
"github.com/grafana/grafana/pkg/web"
|
||||||
@ -34,7 +34,7 @@ func TestAddAppLinks(t *testing.T) {
|
|||||||
{Action: datasources.ActionRead, Scope: "*"},
|
{Action: datasources.ActionRead, Scope: "*"},
|
||||||
}
|
}
|
||||||
|
|
||||||
testApp1 := plugins.PluginDTO{
|
testApp1 := pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test-app1",
|
ID: "test-app1",
|
||||||
Name: "Test app1 name",
|
Name: "Test app1 name",
|
||||||
@ -57,7 +57,7 @@ func TestAddAppLinks(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testApp2 := plugins.PluginDTO{
|
testApp2 := pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test-app2",
|
ID: "test-app2",
|
||||||
Name: "Test app2 name",
|
Name: "Test app2 name",
|
||||||
@ -74,7 +74,7 @@ func TestAddAppLinks(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testApp3 := plugins.PluginDTO{
|
testApp3 := pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test-app3",
|
ID: "test-app3",
|
||||||
Name: "Test app3 name",
|
Name: "Test app3 name",
|
||||||
@ -115,8 +115,8 @@ func TestAddAppLinks(t *testing.T) {
|
|||||||
accessControl: accesscontrolmock.New().WithPermissions(permissions),
|
accessControl: accesscontrolmock.New().WithPermissions(permissions),
|
||||||
pluginSettings: &pluginSettings,
|
pluginSettings: &pluginSettings,
|
||||||
features: featuremgmt.WithFeatures(),
|
features: featuremgmt.WithFeatures(),
|
||||||
pluginStore: &fakes.FakePluginStore{
|
pluginStore: &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{testApp1, testApp2, testApp3},
|
PluginList: []pluginstore.Plugin{testApp1, testApp2, testApp3},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ func TestAddAppLinksAccessControl(t *testing.T) {
|
|||||||
reqCtx := &contextmodel.ReqContext{SignedInUser: user, Context: &web.Context{Req: httpReq}}
|
reqCtx := &contextmodel.ReqContext{SignedInUser: user, Context: &web.Context{Req: httpReq}}
|
||||||
catalogReadAction := "test-app1.catalog:read"
|
catalogReadAction := "test-app1.catalog:read"
|
||||||
|
|
||||||
testApp1 := plugins.PluginDTO{
|
testApp1 := pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test-app1", Name: "Test app1 name", Type: plugins.TypeApp,
|
ID: "test-app1", Name: "Test app1 name", Type: plugins.TypeApp,
|
||||||
Includes: []*plugins.Includes{
|
Includes: []*plugins.Includes{
|
||||||
@ -435,8 +435,8 @@ func TestAddAppLinksAccessControl(t *testing.T) {
|
|||||||
accessControl: acimpl.ProvideAccessControl(cfg),
|
accessControl: acimpl.ProvideAccessControl(cfg),
|
||||||
pluginSettings: &pluginSettings,
|
pluginSettings: &pluginSettings,
|
||||||
features: featuremgmt.WithFeatures(),
|
features: featuremgmt.WithFeatures(),
|
||||||
pluginStore: &fakes.FakePluginStore{
|
pluginStore: &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{testApp1},
|
PluginList: []pluginstore.Plugin{testApp1},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/api/dtos"
|
"github.com/grafana/grafana/pkg/api/dtos"
|
||||||
"github.com/grafana/grafana/pkg/infra/kvstore"
|
"github.com/grafana/grafana/pkg/infra/kvstore"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/apikey"
|
"github.com/grafana/grafana/pkg/services/apikey"
|
||||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||||
@ -18,6 +17,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/navtree"
|
"github.com/grafana/grafana/pkg/services/navtree"
|
||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
pref "github.com/grafana/grafana/pkg/services/preference"
|
pref "github.com/grafana/grafana/pkg/services/preference"
|
||||||
"github.com/grafana/grafana/pkg/services/star"
|
"github.com/grafana/grafana/pkg/services/star"
|
||||||
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlesimpl"
|
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlesimpl"
|
||||||
@ -28,7 +28,7 @@ type ServiceImpl struct {
|
|||||||
cfg *setting.Cfg
|
cfg *setting.Cfg
|
||||||
log log.Logger
|
log log.Logger
|
||||||
accessControl ac.AccessControl
|
accessControl ac.AccessControl
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
pluginSettings pluginsettings.Service
|
pluginSettings pluginsettings.Service
|
||||||
starService star.Service
|
starService star.Service
|
||||||
features *featuremgmt.FeatureManager
|
features *featuremgmt.FeatureManager
|
||||||
@ -50,7 +50,7 @@ type NavigationAppConfig struct {
|
|||||||
Icon string
|
Icon string
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideService(cfg *setting.Cfg, accessControl ac.AccessControl, pluginStore plugins.Store, pluginSettings pluginsettings.Service, starService star.Service, features *featuremgmt.FeatureManager, dashboardService dashboards.DashboardService, accesscontrolService ac.Service, kvStore kvstore.KVStore, apiKeyService apikey.Service, license licensing.Licensing) navtree.Service {
|
func ProvideService(cfg *setting.Cfg, accessControl ac.AccessControl, pluginStore pluginstore.Store, pluginSettings pluginsettings.Service, starService star.Service, features *featuremgmt.FeatureManager, dashboardService dashboards.DashboardService, accesscontrolService ac.Service, kvStore kvstore.KVStore, apiKeyService apikey.Service, license licensing.Licensing) navtree.Service {
|
||||||
service := &ServiceImpl{
|
service := &ServiceImpl{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
log: log.New("navtree service"),
|
log: log.New("navtree service"),
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -88,14 +89,14 @@ type evaluatorImpl struct {
|
|||||||
evaluationTimeout time.Duration
|
evaluationTimeout time.Duration
|
||||||
dataSourceCache datasources.CacheService
|
dataSourceCache datasources.CacheService
|
||||||
expressionService *expr.Service
|
expressionService *expr.Service
|
||||||
pluginsStore plugins.Store
|
pluginsStore pluginstore.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEvaluatorFactory(
|
func NewEvaluatorFactory(
|
||||||
cfg setting.UnifiedAlertingSettings,
|
cfg setting.UnifiedAlertingSettings,
|
||||||
datasourceCache datasources.CacheService,
|
datasourceCache datasources.CacheService,
|
||||||
expressionService *expr.Service,
|
expressionService *expr.Service,
|
||||||
pluginsStore plugins.Store,
|
pluginsStore pluginstore.Store,
|
||||||
) EvaluatorFactory {
|
) EvaluatorFactory {
|
||||||
return &evaluatorImpl{
|
return &evaluatorImpl{
|
||||||
evaluationTimeout: cfg.EvaluationTimeout,
|
evaluationTimeout: cfg.EvaluationTimeout,
|
||||||
|
@ -15,11 +15,11 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/expr"
|
"github.com/grafana/grafana/pkg/expr"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
pluginFakes "github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
fakes "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
fakes "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/user"
|
"github.com/grafana/grafana/pkg/services/user"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
@ -359,7 +359,7 @@ func TestEvaluateExecutionResultsNoData(t *testing.T) {
|
|||||||
func TestValidate(t *testing.T) {
|
func TestValidate(t *testing.T) {
|
||||||
type services struct {
|
type services struct {
|
||||||
cache *fakes.FakeCacheService
|
cache *fakes.FakeCacheService
|
||||||
pluginsStore *pluginFakes.FakePluginStore
|
pluginsStore *pluginstore.FakePluginStore
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -387,7 +387,7 @@ func TestValidate(t *testing.T) {
|
|||||||
Type: util.GenerateShortUID(),
|
Type: util.GenerateShortUID(),
|
||||||
}
|
}
|
||||||
services.cache.DataSources = append(services.cache.DataSources, ds)
|
services.cache.DataSources = append(services.cache.DataSources, ds)
|
||||||
services.pluginsStore.PluginList = append(services.pluginsStore.PluginList, plugins.PluginDTO{
|
services.pluginsStore.PluginList = append(services.pluginsStore.PluginList, pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: ds.Type,
|
ID: ds.Type,
|
||||||
Backend: true,
|
Backend: true,
|
||||||
@ -413,7 +413,7 @@ func TestValidate(t *testing.T) {
|
|||||||
Type: util.GenerateShortUID(),
|
Type: util.GenerateShortUID(),
|
||||||
}
|
}
|
||||||
services.cache.DataSources = append(services.cache.DataSources, ds)
|
services.cache.DataSources = append(services.cache.DataSources, ds)
|
||||||
services.pluginsStore.PluginList = append(services.pluginsStore.PluginList, plugins.PluginDTO{
|
services.pluginsStore.PluginList = append(services.pluginsStore.PluginList, pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: ds.Type,
|
ID: ds.Type,
|
||||||
Backend: true,
|
Backend: true,
|
||||||
@ -476,12 +476,12 @@ func TestValidate(t *testing.T) {
|
|||||||
Type: util.GenerateShortUID(),
|
Type: util.GenerateShortUID(),
|
||||||
}
|
}
|
||||||
services.cache.DataSources = append(services.cache.DataSources, ds1, ds2)
|
services.cache.DataSources = append(services.cache.DataSources, ds1, ds2)
|
||||||
services.pluginsStore.PluginList = append(services.pluginsStore.PluginList, plugins.PluginDTO{
|
services.pluginsStore.PluginList = append(services.pluginsStore.PluginList, pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: ds1.Type,
|
ID: ds1.Type,
|
||||||
Backend: false,
|
Backend: false,
|
||||||
},
|
},
|
||||||
}, plugins.PluginDTO{
|
}, pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: ds2.Type,
|
ID: ds2.Type,
|
||||||
Backend: true,
|
Backend: true,
|
||||||
@ -507,7 +507,7 @@ func TestValidate(t *testing.T) {
|
|||||||
Type: util.GenerateShortUID(),
|
Type: util.GenerateShortUID(),
|
||||||
}
|
}
|
||||||
services.cache.DataSources = append(services.cache.DataSources, ds)
|
services.cache.DataSources = append(services.cache.DataSources, ds)
|
||||||
services.pluginsStore.PluginList = append(services.pluginsStore.PluginList, plugins.PluginDTO{
|
services.pluginsStore.PluginList = append(services.pluginsStore.PluginList, pluginstore.Plugin{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: ds.Type,
|
ID: ds.Type,
|
||||||
Backend: true,
|
Backend: true,
|
||||||
@ -530,7 +530,7 @@ func TestValidate(t *testing.T) {
|
|||||||
|
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
cacheService := &fakes.FakeCacheService{}
|
cacheService := &fakes.FakeCacheService{}
|
||||||
store := &pluginFakes.FakePluginStore{}
|
store := &pluginstore.FakePluginStore{}
|
||||||
condition := testCase.condition(services{
|
condition := testCase.condition(services{
|
||||||
cache: cacheService,
|
cache: cacheService,
|
||||||
pluginsStore: store,
|
pluginsStore: store,
|
||||||
|
@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/kvstore"
|
"github.com/grafana/grafana/pkg/infra/kvstore"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/annotations"
|
"github.com/grafana/grafana/pkg/services/annotations"
|
||||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||||
@ -38,6 +37,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/ngalert/state/historian"
|
"github.com/grafana/grafana/pkg/services/ngalert/state/historian"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/store"
|
"github.com/grafana/grafana/pkg/services/ngalert/store"
|
||||||
"github.com/grafana/grafana/pkg/services/notifications"
|
"github.com/grafana/grafana/pkg/services/notifications"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/quota"
|
"github.com/grafana/grafana/pkg/services/quota"
|
||||||
"github.com/grafana/grafana/pkg/services/rendering"
|
"github.com/grafana/grafana/pkg/services/rendering"
|
||||||
"github.com/grafana/grafana/pkg/services/secrets"
|
"github.com/grafana/grafana/pkg/services/secrets"
|
||||||
@ -65,7 +65,7 @@ func ProvideService(
|
|||||||
bus bus.Bus,
|
bus bus.Bus,
|
||||||
accesscontrolService accesscontrol.Service,
|
accesscontrolService accesscontrol.Service,
|
||||||
annotationsRepo annotations.Repository,
|
annotationsRepo annotations.Repository,
|
||||||
pluginsStore plugins.Store,
|
pluginsStore pluginstore.Store,
|
||||||
tracer tracing.Tracer,
|
tracer tracing.Tracer,
|
||||||
ruleStore *store.DBstore,
|
ruleStore *store.DBstore,
|
||||||
) (*AlertNG, error) {
|
) (*AlertNG, error) {
|
||||||
@ -140,7 +140,7 @@ type AlertNG struct {
|
|||||||
store *store.DBstore
|
store *store.DBstore
|
||||||
|
|
||||||
bus bus.Bus
|
bus bus.Bus
|
||||||
pluginsStore plugins.Store
|
pluginsStore pluginstore.Store
|
||||||
tracer tracing.Tracer
|
tracer tracing.Tracer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,13 +23,13 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/expr"
|
"github.com/grafana/grafana/pkg/expr"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/eval"
|
"github.com/grafana/grafana/pkg/services/ngalert/eval"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/state"
|
"github.com/grafana/grafana/pkg/services/ngalert/state"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
@ -855,7 +855,7 @@ func setupScheduler(t *testing.T, rs *fakeRulesStore, is *state.FakeInstanceStor
|
|||||||
|
|
||||||
var evaluator = evalMock
|
var evaluator = evalMock
|
||||||
if evalMock == nil {
|
if evalMock == nil {
|
||||||
evaluator = eval.NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, nil, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil, &featuremgmt.FeatureManager{}, nil, tracing.InitializeTracerForTest()), &fakes.FakePluginStore{})
|
evaluator = eval.NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, nil, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil, &featuremgmt.FeatureManager{}, nil, tracing.InitializeTracerForTest()), &pluginstore.FakePluginStore{})
|
||||||
}
|
}
|
||||||
|
|
||||||
if registry == nil {
|
if registry == nil {
|
||||||
|
@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/db"
|
"github.com/grafana/grafana/pkg/infra/db"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||||
"github.com/grafana/grafana/pkg/services/annotations/annotationstest"
|
"github.com/grafana/grafana/pkg/services/annotations/annotationstest"
|
||||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||||
@ -30,6 +29,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/ngalert/store"
|
"github.com/grafana/grafana/pkg/services/ngalert/store"
|
||||||
"github.com/grafana/grafana/pkg/services/ngalert/testutil"
|
"github.com/grafana/grafana/pkg/services/ngalert/testutil"
|
||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/database"
|
"github.com/grafana/grafana/pkg/services/secrets/database"
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
||||||
@ -68,7 +68,7 @@ func SetupTestEnv(tb testing.TB, baseInterval time.Duration) (*ngalert.AlertNG,
|
|||||||
ng, err := ngalert.ProvideService(
|
ng, err := ngalert.ProvideService(
|
||||||
cfg, featuremgmt.WithFeatures(), nil, nil, routing.NewRouteRegister(), sqlStore, nil, nil, nil, quotatest.New(false, nil),
|
cfg, featuremgmt.WithFeatures(), nil, nil, routing.NewRouteRegister(), sqlStore, nil, nil, nil, quotatest.New(false, nil),
|
||||||
secretsService, nil, m, folderService, ac, &dashboards.FakeDashboardService{}, nil, bus, ac,
|
secretsService, nil, m, folderService, ac, &dashboards.FakeDashboardService{}, nil, bus, ac,
|
||||||
annotationstest.NewFakeAnnotationsRepo(), &fakes.FakePluginStore{}, tracer, ruleStore,
|
annotationstest.NewFakeAnnotationsRepo(), &pluginstore.FakePluginStore{}, tracer, ruleStore,
|
||||||
)
|
)
|
||||||
require.NoError(tb, err)
|
require.NoError(tb, err)
|
||||||
return ng, &store.DBstore{
|
return ng, &store.DBstore{
|
||||||
|
@ -6,16 +6,16 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/dashboardimport"
|
"github.com/grafana/grafana/pkg/services/dashboardimport"
|
||||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ProvideDashboardUpdater(bus bus.Bus, pluginStore plugins.Store, pluginDashboardService plugindashboards.Service,
|
func ProvideDashboardUpdater(bus bus.Bus, pluginStore pluginstore.Store, pluginDashboardService plugindashboards.Service,
|
||||||
dashboardImportService dashboardimport.Service, pluginSettingsService pluginsettings.Service,
|
dashboardImportService dashboardimport.Service, pluginSettingsService pluginsettings.Service,
|
||||||
dashboardPluginService dashboards.PluginService, dashboardService dashboards.DashboardService) *DashboardUpdater {
|
dashboardPluginService dashboards.PluginService, dashboardService dashboards.DashboardService) *DashboardUpdater {
|
||||||
du := newDashboardUpdater(bus, pluginStore, pluginDashboardService, dashboardImportService,
|
du := newDashboardUpdater(bus, pluginStore, pluginDashboardService, dashboardImportService,
|
||||||
@ -24,7 +24,7 @@ func ProvideDashboardUpdater(bus bus.Bus, pluginStore plugins.Store, pluginDashb
|
|||||||
return du
|
return du
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDashboardUpdater(bus bus.Bus, pluginStore plugins.Store,
|
func newDashboardUpdater(bus bus.Bus, pluginStore pluginstore.Store,
|
||||||
pluginDashboardService plugindashboards.Service, dashboardImportService dashboardimport.Service,
|
pluginDashboardService plugindashboards.Service, dashboardImportService dashboardimport.Service,
|
||||||
pluginSettingsService pluginsettings.Service, dashboardPluginService dashboards.PluginService,
|
pluginSettingsService pluginsettings.Service, dashboardPluginService dashboards.PluginService,
|
||||||
dashboardService dashboards.DashboardService) *DashboardUpdater {
|
dashboardService dashboards.DashboardService) *DashboardUpdater {
|
||||||
@ -43,7 +43,7 @@ func newDashboardUpdater(bus bus.Bus, pluginStore plugins.Store,
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DashboardUpdater struct {
|
type DashboardUpdater struct {
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
pluginDashboardService plugindashboards.Service
|
pluginDashboardService plugindashboards.Service
|
||||||
dashboardImportService dashboardimport.Service
|
dashboardImportService dashboardimport.Service
|
||||||
pluginSettingsService pluginsettings.Service
|
pluginSettingsService pluginsettings.Service
|
||||||
@ -75,7 +75,7 @@ func (du *DashboardUpdater) updateAppDashboards() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (du *DashboardUpdater) syncPluginDashboards(ctx context.Context, plugin plugins.PluginDTO, orgID int64) {
|
func (du *DashboardUpdater) syncPluginDashboards(ctx context.Context, plugin pluginstore.Plugin, orgID int64) {
|
||||||
du.logger.Info("Syncing plugin dashboards to DB", "pluginId", plugin.ID)
|
du.logger.Info("Syncing plugin dashboards to DB", "pluginId", plugin.ID)
|
||||||
|
|
||||||
// Get plugin dashboards
|
// Get plugin dashboards
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDashboardUpdater(t *testing.T) {
|
func TestDashboardUpdater(t *testing.T) {
|
||||||
@ -83,7 +84,7 @@ func TestDashboardUpdater(t *testing.T) {
|
|||||||
PluginVersion: "1.0.0",
|
PluginVersion: "1.0.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
installedPlugins: []plugins.PluginDTO{
|
installedPlugins: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
Info: plugins.Info{
|
Info: plugins.Info{
|
||||||
@ -115,7 +116,7 @@ func TestDashboardUpdater(t *testing.T) {
|
|||||||
PluginVersion: "1.0.0",
|
PluginVersion: "1.0.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
installedPlugins: []plugins.PluginDTO{
|
installedPlugins: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
Info: plugins.Info{
|
Info: plugins.Info{
|
||||||
@ -151,7 +152,7 @@ func TestDashboardUpdater(t *testing.T) {
|
|||||||
OrgID: 2,
|
OrgID: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
installedPlugins: []plugins.PluginDTO{
|
installedPlugins: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test",
|
ID: "test",
|
||||||
@ -225,7 +226,7 @@ func TestDashboardUpdater(t *testing.T) {
|
|||||||
OrgID: 2,
|
OrgID: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
installedPlugins: []plugins.PluginDTO{
|
installedPlugins: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test",
|
ID: "test",
|
||||||
@ -273,7 +274,7 @@ func TestDashboardUpdater(t *testing.T) {
|
|||||||
PluginVersion: "1.0.0",
|
PluginVersion: "1.0.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
installedPlugins: []plugins.PluginDTO{
|
installedPlugins: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test",
|
ID: "test",
|
||||||
@ -341,16 +342,16 @@ func TestDashboardUpdater(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type pluginStoreMock struct {
|
type pluginStoreMock struct {
|
||||||
plugins.Store
|
pluginstore.Store
|
||||||
pluginFunc func(ctx context.Context, pluginID string) (plugins.PluginDTO, bool)
|
pluginFunc func(ctx context.Context, pluginID string) (pluginstore.Plugin, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *pluginStoreMock) Plugin(ctx context.Context, pluginID string) (plugins.PluginDTO, bool) {
|
func (m *pluginStoreMock) Plugin(ctx context.Context, pluginID string) (pluginstore.Plugin, bool) {
|
||||||
if m.pluginFunc != nil {
|
if m.pluginFunc != nil {
|
||||||
return m.pluginFunc(ctx, pluginID)
|
return m.pluginFunc(ctx, pluginID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return plugins.PluginDTO{}, false
|
return pluginstore.Plugin{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
type pluginDashboardServiceMock struct {
|
type pluginDashboardServiceMock struct {
|
||||||
@ -464,7 +465,7 @@ func (s *dashboardServiceMock) GetDashboardByPublicUid(ctx context.Context, dash
|
|||||||
|
|
||||||
type scenarioInput struct {
|
type scenarioInput struct {
|
||||||
storedPluginSettings []*pluginsettings.DTO
|
storedPluginSettings []*pluginsettings.DTO
|
||||||
installedPlugins []plugins.PluginDTO
|
installedPlugins []pluginstore.Plugin
|
||||||
pluginDashboards []*plugindashboards.PluginDashboard
|
pluginDashboards []*plugindashboards.PluginDashboard
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +473,7 @@ type scenarioContext struct {
|
|||||||
t *testing.T
|
t *testing.T
|
||||||
bus bus.Bus
|
bus bus.Bus
|
||||||
pluginSettingsService *pluginsSettingsServiceMock
|
pluginSettingsService *pluginsSettingsServiceMock
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
pluginDashboardService plugindashboards.Service
|
pluginDashboardService plugindashboards.Service
|
||||||
importDashboardService dashboardimport.Service
|
importDashboardService dashboardimport.Service
|
||||||
dashboardPluginService *dashboardPluginServiceMock
|
dashboardPluginService *dashboardPluginServiceMock
|
||||||
@ -496,14 +497,14 @@ func scenario(t *testing.T, desc string, input scenarioInput, f func(ctx *scenar
|
|||||||
updatePluginSettingVersionArgs: []*pluginsettings.UpdatePluginSettingVersionCmd{},
|
updatePluginSettingVersionArgs: []*pluginsettings.UpdatePluginSettingVersionCmd{},
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlugin := func(ctx context.Context, pluginID string) (plugins.PluginDTO, bool) {
|
getPlugin := func(ctx context.Context, pluginID string) (pluginstore.Plugin, bool) {
|
||||||
for _, p := range input.installedPlugins {
|
for _, p := range input.installedPlugins {
|
||||||
if p.ID == pluginID {
|
if p.ID == pluginID {
|
||||||
return p, true
|
return p, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return plugins.PluginDTO{}, false
|
return pluginstore.Plugin{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
sCtx.pluginSettingsService = &pluginsSettingsServiceMock{
|
sCtx.pluginSettingsService = &pluginsSettingsServiceMock{
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
pluginDashboardsManager "github.com/grafana/grafana/pkg/plugins/manager/dashboards"
|
|
||||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||||
|
pluginDashboardsManager "github.com/grafana/grafana/pkg/services/pluginsintegration/dashboards"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ProvideService(pluginDashboardStore pluginDashboardsManager.FileStore, dashboardPluginService dashboards.PluginService) *Service {
|
func ProvideService(pluginDashboardStore pluginDashboardsManager.FileStore, dashboardPluginService dashboards.PluginService) *Service {
|
||||||
|
@ -10,9 +10,9 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/dashboards"
|
|
||||||
dashmodels "github.com/grafana/grafana/pkg/services/dashboards"
|
dashmodels "github.com/grafana/grafana/pkg/services/dashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/dashboards"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetPluginDashboards(t *testing.T) {
|
func TestGetPluginDashboards(t *testing.T) {
|
||||||
|
@ -6,17 +6,18 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ FileStore = (*FileStoreManager)(nil)
|
var _ FileStore = (*FileStoreManager)(nil)
|
||||||
|
|
||||||
type FileStoreManager struct {
|
type FileStoreManager struct {
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
pluginFileStore plugins.FileStore
|
pluginFileStore plugins.FileStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideFileStoreManager(pluginStore plugins.Store, pluginFileStore plugins.FileStore) *FileStoreManager {
|
func ProvideFileStoreManager(pluginStore pluginstore.Store, pluginFileStore plugins.FileStore) *FileStoreManager {
|
||||||
return &FileStoreManager{
|
return &FileStoreManager{
|
||||||
pluginStore: pluginStore,
|
pluginStore: pluginStore,
|
||||||
pluginFileStore: pluginFileStore,
|
pluginFileStore: pluginFileStore,
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDashboardFileStore(t *testing.T) {
|
func TestDashboardFileStore(t *testing.T) {
|
||||||
@ -221,8 +221,8 @@ func setupPluginDashboardsForTest(t *testing.T) *FileStoreManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &FileStoreManager{
|
return &FileStoreManager{
|
||||||
pluginStore: &fakes.FakePluginStore{
|
pluginStore: &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{p1.ToDTO(), p2.ToDTO()},
|
PluginList: []pluginstore.Plugin{pluginstore.ToGrafanaDTO(p1), pluginstore.ToGrafanaDTO(p2)},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,16 +10,16 @@ import (
|
|||||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/localcache"
|
"github.com/grafana/grafana/pkg/infra/localcache"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/adapters"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/adapters"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrPluginNotFound = errors.New("plugin not found")
|
var ErrPluginNotFound = errors.New("plugin not found")
|
||||||
|
|
||||||
func ProvideService(cacheService *localcache.CacheService, pluginStore plugins.Store,
|
func ProvideService(cacheService *localcache.CacheService, pluginStore pluginstore.Store,
|
||||||
dataSourceService datasources.DataSourceService, pluginSettingsService pluginsettings.Service) *Provider {
|
dataSourceService datasources.DataSourceService, pluginSettingsService pluginsettings.Service) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
cacheService: cacheService,
|
cacheService: cacheService,
|
||||||
@ -31,7 +31,7 @@ func ProvideService(cacheService *localcache.CacheService, pluginStore plugins.S
|
|||||||
|
|
||||||
type Provider struct {
|
type Provider struct {
|
||||||
cacheService *localcache.CacheService
|
cacheService *localcache.CacheService
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
dataSourceService datasources.DataSourceService
|
dataSourceService datasources.DataSourceService
|
||||||
pluginSettingsService pluginsettings.Service
|
pluginSettingsService pluginsettings.Service
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
|
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/store"
|
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/searchV2"
|
"github.com/grafana/grafana/pkg/services/searchV2"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
|
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
|
||||||
@ -134,7 +134,7 @@ func verifyPluginQuery(t *testing.T, ctx context.Context, c plugins.Client) {
|
|||||||
require.JSONEq(t, `{"results":{"A":{"frames":[{"schema":{"refId":"A","fields":[{"name":"time","type":"time","typeInfo":{"frame":"time.Time"}},{"name":"A-series","type":"number","typeInfo":{"frame":"int64","nullable":true}}]},"data":{"values":[[1661420570000,1661420630000,1661420690000,1661420750000,1661420810000,1661420870000],[1,20,90,30,5,0]]}}],"status":200}}}`, string(payload))
|
require.JSONEq(t, `{"results":{"A":{"frames":[{"schema":{"refId":"A","fields":[{"name":"time","type":"time","typeInfo":{"frame":"time.Time"}},{"name":"A-series","type":"number","typeInfo":{"frame":"int64","nullable":true}}]},"data":{"values":[[1661420570000,1661420630000,1661420690000,1661420750000,1661420810000,1661420870000],[1,20,90,30,5,0]]}}],"status":200}}}`, string(payload))
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyCorePluginCatalogue(t *testing.T, ctx context.Context, ps *store.Service) {
|
func verifyCorePluginCatalogue(t *testing.T, ctx context.Context, ps *pluginstore.Service) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
expPanels := map[string]struct{}{
|
expPanels := map[string]struct{}{
|
||||||
@ -207,7 +207,7 @@ func verifyCorePluginCatalogue(t *testing.T, ctx context.Context, ps *store.Serv
|
|||||||
require.Equal(t, len(expPanels), len(panels))
|
require.Equal(t, len(expPanels), len(panels))
|
||||||
for _, p := range panels {
|
for _, p := range panels {
|
||||||
p, exists := ps.Plugin(ctx, p.ID)
|
p, exists := ps.Plugin(ctx, p.ID)
|
||||||
require.NotEqual(t, plugins.PluginDTO{}, p)
|
require.NotEqual(t, pluginstore.Plugin{}, p)
|
||||||
require.True(t, exists)
|
require.True(t, exists)
|
||||||
require.Contains(t, expPanels, p.ID)
|
require.Contains(t, expPanels, p.ID)
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ func verifyCorePluginCatalogue(t *testing.T, ctx context.Context, ps *store.Serv
|
|||||||
require.Equal(t, len(expDataSources), len(dataSources))
|
require.Equal(t, len(expDataSources), len(dataSources))
|
||||||
for _, ds := range dataSources {
|
for _, ds := range dataSources {
|
||||||
p, exists := ps.Plugin(ctx, ds.ID)
|
p, exists := ps.Plugin(ctx, ds.ID)
|
||||||
require.NotEqual(t, plugins.PluginDTO{}, p)
|
require.NotEqual(t, pluginstore.Plugin{}, p)
|
||||||
require.True(t, exists)
|
require.True(t, exists)
|
||||||
require.Contains(t, expDataSources, ds.ID)
|
require.Contains(t, expDataSources, ds.ID)
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ func verifyCorePluginCatalogue(t *testing.T, ctx context.Context, ps *store.Serv
|
|||||||
require.Equal(t, len(expPanels)+len(expDataSources)+len(expApps), len(ps.Plugins(ctx)))
|
require.Equal(t, len(expPanels)+len(expDataSources)+len(expApps), len(ps.Plugins(ctx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyBundledPlugins(t *testing.T, ctx context.Context, ps *store.Service) {
|
func verifyBundledPlugins(t *testing.T, ctx context.Context, ps *pluginstore.Service) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
dsPlugins := make(map[string]struct{})
|
dsPlugins := make(map[string]struct{})
|
||||||
@ -243,7 +243,7 @@ func verifyBundledPlugins(t *testing.T, ctx context.Context, ps *store.Service)
|
|||||||
|
|
||||||
inputPlugin, exists := ps.Plugin(ctx, "input")
|
inputPlugin, exists := ps.Plugin(ctx, "input")
|
||||||
require.True(t, exists)
|
require.True(t, exists)
|
||||||
require.NotEqual(t, plugins.PluginDTO{}, inputPlugin)
|
require.NotEqual(t, pluginstore.Plugin{}, inputPlugin)
|
||||||
require.NotNil(t, dsPlugins["input"])
|
require.NotNil(t, dsPlugins["input"])
|
||||||
|
|
||||||
pluginRoutes := make(map[string]*plugins.StaticRoute)
|
pluginRoutes := make(map[string]*plugins.StaticRoute)
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/signature"
|
"github.com/grafana/grafana/pkg/plugins/manager/signature"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/sources"
|
"github.com/grafana/grafana/pkg/plugins/manager/sources"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/store"
|
|
||||||
"github.com/grafana/grafana/pkg/plugins/oauth"
|
"github.com/grafana/grafana/pkg/plugins/oauth"
|
||||||
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
||||||
"github.com/grafana/grafana/pkg/plugins/repo"
|
"github.com/grafana/grafana/pkg/plugins/repo"
|
||||||
@ -46,6 +45,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/serviceregistration"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/serviceregistration"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
@ -53,11 +53,11 @@ import (
|
|||||||
// WireSet provides a wire.ProviderSet of plugin providers.
|
// WireSet provides a wire.ProviderSet of plugin providers.
|
||||||
var WireSet = wire.NewSet(
|
var WireSet = wire.NewSet(
|
||||||
config.ProvideConfig,
|
config.ProvideConfig,
|
||||||
store.ProvideService,
|
pluginstore.ProvideService,
|
||||||
wire.Bind(new(plugins.Store), new(*store.Service)),
|
wire.Bind(new(pluginstore.Store), new(*pluginstore.Service)),
|
||||||
wire.Bind(new(plugins.RendererManager), new(*store.Service)),
|
wire.Bind(new(plugins.RendererManager), new(*pluginstore.Service)),
|
||||||
wire.Bind(new(plugins.SecretsPluginManager), new(*store.Service)),
|
wire.Bind(new(plugins.SecretsPluginManager), new(*pluginstore.Service)),
|
||||||
wire.Bind(new(plugins.StaticRouteResolver), new(*store.Service)),
|
wire.Bind(new(plugins.StaticRouteResolver), new(*pluginstore.Service)),
|
||||||
ProvideClientDecorator,
|
ProvideClientDecorator,
|
||||||
wire.Bind(new(plugins.Client), new(*client.Decorator)),
|
wire.Bind(new(plugins.Client), new(*client.Decorator)),
|
||||||
process.ProvideService,
|
process.ProvideService,
|
||||||
|
38
pkg/services/pluginsintegration/pluginstore/fake.go
Normal file
38
pkg/services/pluginsintegration/pluginstore/fake.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package pluginstore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FakePluginStore struct {
|
||||||
|
PluginList []Plugin
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pr *FakePluginStore) Plugin(_ context.Context, pluginID string) (Plugin, bool) {
|
||||||
|
for _, v := range pr.PluginList {
|
||||||
|
if v.ID == pluginID {
|
||||||
|
return v, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Plugin{}, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pr *FakePluginStore) Plugins(_ context.Context, pluginTypes ...plugins.Type) []Plugin {
|
||||||
|
var result []Plugin
|
||||||
|
if len(pluginTypes) == 0 {
|
||||||
|
pluginTypes = plugins.PluginTypes
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range pr.PluginList {
|
||||||
|
for _, t := range pluginTypes {
|
||||||
|
if v.Type == t {
|
||||||
|
result = append(result, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
78
pkg/services/pluginsintegration/pluginstore/plugins.go
Normal file
78
pkg/services/pluginsintegration/pluginstore/plugins.go
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package pluginstore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Plugin struct {
|
||||||
|
plugins.JSONData
|
||||||
|
|
||||||
|
fs plugins.FS
|
||||||
|
supportsStreaming bool
|
||||||
|
|
||||||
|
Class plugins.Class
|
||||||
|
|
||||||
|
// App fields
|
||||||
|
IncludedInAppID string
|
||||||
|
DefaultNavURL string
|
||||||
|
Pinned bool
|
||||||
|
|
||||||
|
// Signature fields
|
||||||
|
Signature plugins.SignatureStatus
|
||||||
|
SignatureType plugins.SignatureType
|
||||||
|
SignatureOrg string
|
||||||
|
SignatureError *plugins.SignatureError
|
||||||
|
|
||||||
|
// SystemJS fields
|
||||||
|
Module string
|
||||||
|
BaseURL string
|
||||||
|
|
||||||
|
AngularDetected bool
|
||||||
|
|
||||||
|
// This will be moved to plugin.json when we have general support in gcom
|
||||||
|
Alias string `json:"alias,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Plugin) SupportsStreaming() bool {
|
||||||
|
return p.supportsStreaming
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Plugin) Base() string {
|
||||||
|
return p.fs.Base()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Plugin) IsApp() bool {
|
||||||
|
return p.Type == plugins.TypeApp
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Plugin) IsCorePlugin() bool {
|
||||||
|
return p.Class == plugins.ClassCore
|
||||||
|
}
|
||||||
|
|
||||||
|
func ToGrafanaDTO(p *plugins.Plugin) Plugin {
|
||||||
|
supportsStreaming := false
|
||||||
|
pc, exists := p.Client()
|
||||||
|
if exists && pc != nil && pc.(backend.StreamHandler) != nil {
|
||||||
|
supportsStreaming = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return Plugin{
|
||||||
|
fs: p.FS,
|
||||||
|
supportsStreaming: supportsStreaming,
|
||||||
|
Class: p.Class,
|
||||||
|
JSONData: p.JSONData,
|
||||||
|
IncludedInAppID: p.IncludedInAppID,
|
||||||
|
DefaultNavURL: p.DefaultNavURL,
|
||||||
|
Pinned: p.Pinned,
|
||||||
|
Signature: p.Signature,
|
||||||
|
SignatureType: p.SignatureType,
|
||||||
|
SignatureOrg: p.SignatureOrg,
|
||||||
|
SignatureError: p.SignatureError,
|
||||||
|
Module: p.Module,
|
||||||
|
BaseURL: p.BaseURL,
|
||||||
|
AngularDetected: p.AngularDetected,
|
||||||
|
Alias: p.Alias,
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package store
|
package pluginstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -11,7 +11,15 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins/manager/sources"
|
"github.com/grafana/grafana/pkg/plugins/manager/sources"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ plugins.Store = (*Service)(nil)
|
var _ Store = (*Service)(nil)
|
||||||
|
|
||||||
|
// Store is the publicly accessible storage for plugins.
|
||||||
|
type Store interface {
|
||||||
|
// Plugin finds a plugin by its ID.
|
||||||
|
Plugin(ctx context.Context, pluginID string) (Plugin, bool)
|
||||||
|
// Plugins returns plugins by their requested type.
|
||||||
|
Plugins(ctx context.Context, pluginTypes ...plugins.Type) []Plugin
|
||||||
|
}
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
pluginRegistry registry.Service
|
pluginRegistry registry.Service
|
||||||
@ -42,16 +50,16 @@ func New(pluginRegistry registry.Service, pluginLoader loader.Service) *Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Plugin(ctx context.Context, pluginID string) (plugins.PluginDTO, bool) {
|
func (s *Service) Plugin(ctx context.Context, pluginID string) (Plugin, bool) {
|
||||||
p, exists := s.plugin(ctx, pluginID)
|
p, exists := s.plugin(ctx, pluginID)
|
||||||
if !exists {
|
if !exists {
|
||||||
return plugins.PluginDTO{}, false
|
return Plugin{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.ToDTO(), true
|
return ToGrafanaDTO(p), true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Plugins(ctx context.Context, pluginTypes ...plugins.Type) []plugins.PluginDTO {
|
func (s *Service) Plugins(ctx context.Context, pluginTypes ...plugins.Type) []Plugin {
|
||||||
// if no types passed, assume all
|
// if no types passed, assume all
|
||||||
if len(pluginTypes) == 0 {
|
if len(pluginTypes) == 0 {
|
||||||
pluginTypes = plugins.PluginTypes
|
pluginTypes = plugins.PluginTypes
|
||||||
@ -62,10 +70,10 @@ func (s *Service) Plugins(ctx context.Context, pluginTypes ...plugins.Type) []pl
|
|||||||
requestedTypes[pt] = struct{}{}
|
requestedTypes[pt] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginsList := make([]plugins.PluginDTO, 0)
|
pluginsList := make([]Plugin, 0)
|
||||||
for _, p := range s.availablePlugins(ctx) {
|
for _, p := range s.availablePlugins(ctx) {
|
||||||
if _, exists := requestedTypes[p.Type]; exists {
|
if _, exists := requestedTypes[p.Type]; exists {
|
||||||
pluginsList = append(pluginsList, p.ToDTO())
|
pluginsList = append(pluginsList, ToGrafanaDTO(p))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pluginsList
|
return pluginsList
|
@ -1,4 +1,4 @@
|
|||||||
package store
|
package pluginstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -65,11 +65,11 @@ func TestStore_Plugin(t *testing.T) {
|
|||||||
|
|
||||||
p, exists := ps.Plugin(context.Background(), p1.ID)
|
p, exists := ps.Plugin(context.Background(), p1.ID)
|
||||||
require.False(t, exists)
|
require.False(t, exists)
|
||||||
require.Equal(t, plugins.PluginDTO{}, p)
|
require.Equal(t, Plugin{}, p)
|
||||||
|
|
||||||
p, exists = ps.Plugin(context.Background(), p2.ID)
|
p, exists = ps.Plugin(context.Background(), p2.ID)
|
||||||
require.True(t, exists)
|
require.True(t, exists)
|
||||||
require.Equal(t, p, p2.ToDTO())
|
require.Equal(t, p, ToGrafanaDTO(p2))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,20 +92,27 @@ func TestStore_Plugins(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}, &fakes.FakeLoader{})
|
}, &fakes.FakeLoader{})
|
||||||
|
|
||||||
|
ToGrafanaDTO(p1)
|
||||||
pss := ps.Plugins(context.Background())
|
pss := ps.Plugins(context.Background())
|
||||||
require.Equal(t, pss, []plugins.PluginDTO{p1.ToDTO(), p2.ToDTO(), p3.ToDTO(), p4.ToDTO()})
|
require.Equal(t, pss, []Plugin{
|
||||||
|
ToGrafanaDTO(p1), ToGrafanaDTO(p2),
|
||||||
|
ToGrafanaDTO(p3), ToGrafanaDTO(p4),
|
||||||
|
})
|
||||||
|
|
||||||
pss = ps.Plugins(context.Background(), plugins.TypeApp)
|
pss = ps.Plugins(context.Background(), plugins.TypeApp)
|
||||||
require.Equal(t, pss, []plugins.PluginDTO{p4.ToDTO()})
|
require.Equal(t, pss, []Plugin{ToGrafanaDTO(p4)})
|
||||||
|
|
||||||
pss = ps.Plugins(context.Background(), plugins.TypePanel)
|
pss = ps.Plugins(context.Background(), plugins.TypePanel)
|
||||||
require.Equal(t, pss, []plugins.PluginDTO{p2.ToDTO(), p3.ToDTO()})
|
require.Equal(t, pss, []Plugin{ToGrafanaDTO(p2), ToGrafanaDTO(p3)})
|
||||||
|
|
||||||
pss = ps.Plugins(context.Background(), plugins.TypeDataSource)
|
pss = ps.Plugins(context.Background(), plugins.TypeDataSource)
|
||||||
require.Equal(t, pss, []plugins.PluginDTO{p1.ToDTO()})
|
require.Equal(t, pss, []Plugin{ToGrafanaDTO(p1)})
|
||||||
|
|
||||||
pss = ps.Plugins(context.Background(), plugins.TypeDataSource, plugins.TypeApp, plugins.TypePanel)
|
pss = ps.Plugins(context.Background(), plugins.TypeDataSource, plugins.TypeApp, plugins.TypePanel)
|
||||||
require.Equal(t, pss, []plugins.PluginDTO{p1.ToDTO(), p2.ToDTO(), p3.ToDTO(), p4.ToDTO()})
|
require.Equal(t, pss, []Plugin{
|
||||||
|
ToGrafanaDTO(p1), ToGrafanaDTO(p2),
|
||||||
|
ToGrafanaDTO(p3), ToGrafanaDTO(p4),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -26,18 +26,18 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins/manager/signature"
|
"github.com/grafana/grafana/pkg/plugins/manager/signature"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/signature/statickey"
|
"github.com/grafana/grafana/pkg/plugins/manager/signature/statickey"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/sources"
|
"github.com/grafana/grafana/pkg/plugins/manager/sources"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/store"
|
|
||||||
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/config"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/config"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pipeline"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pipeline"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IntegrationTestCtx struct {
|
type IntegrationTestCtx struct {
|
||||||
PluginClient plugins.Client
|
PluginClient plugins.Client
|
||||||
PluginStore *store.Service
|
PluginStore *pluginstore.Service
|
||||||
PluginRegistry registry.Service
|
PluginRegistry registry.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ func CreateIntegrationTestCtx(t *testing.T, cfg *setting.Cfg, coreRegistry *core
|
|||||||
Terminator: term,
|
Terminator: term,
|
||||||
})
|
})
|
||||||
|
|
||||||
ps, err := store.ProvideService(reg, sources.ProvideService(cfg, pCfg), l)
|
ps, err := pluginstore.ProvideService(reg, sources.ProvideService(cfg, pCfg), l)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return &IntegrationTestCtx{
|
return &IntegrationTestCtx{
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type configReader interface {
|
type configReader interface {
|
||||||
@ -20,10 +20,10 @@ type configReader interface {
|
|||||||
|
|
||||||
type configReaderImpl struct {
|
type configReaderImpl struct {
|
||||||
log log.Logger
|
log log.Logger
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConfigReader(logger log.Logger, pluginStore plugins.Store) configReader {
|
func newConfigReader(logger log.Logger, pluginStore pluginstore.Store) configReader {
|
||||||
return &configReaderImpl{log: logger, pluginStore: pluginStore}
|
return &configReaderImpl{log: logger, pluginStore: pluginStore}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -34,7 +34,7 @@ func TestConfigReader(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Unknown app plugin should return error", func(t *testing.T) {
|
t.Run("Unknown app plugin should return error", func(t *testing.T) {
|
||||||
cfgProvider := newConfigReader(log.New("test logger"), &fakes.FakePluginStore{})
|
cfgProvider := newConfigReader(log.New("test logger"), &pluginstore.FakePluginStore{})
|
||||||
_, err := cfgProvider.readConfig(context.Background(), unknownApp)
|
_, err := cfgProvider.readConfig(context.Background(), unknownApp)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, "plugin not installed: \"nonexisting\"", err.Error())
|
require.Equal(t, "plugin not installed: \"nonexisting\"", err.Error())
|
||||||
@ -48,8 +48,8 @@ func TestConfigReader(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Can read correct properties", func(t *testing.T) {
|
t.Run("Can read correct properties", func(t *testing.T) {
|
||||||
pm := &fakes.FakePluginStore{
|
pm := &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{JSONData: plugins.JSONData{ID: "test-plugin"}},
|
{JSONData: plugins.JSONData{ID: "test-plugin"}},
|
||||||
{JSONData: plugins.JSONData{ID: "test-plugin-2"}},
|
{JSONData: plugins.JSONData{ID: "test-plugin-2"}},
|
||||||
},
|
},
|
||||||
|
@ -5,14 +5,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Provision scans a directory for provisioning config files
|
// Provision scans a directory for provisioning config files
|
||||||
// and provisions the app in those files.
|
// and provisions the app in those files.
|
||||||
func Provision(ctx context.Context, configDirectory string, pluginStore plugins.Store, pluginSettings pluginsettings.Service, orgService org.Service) error {
|
func Provision(ctx context.Context, configDirectory string, pluginStore pluginstore.Store, pluginSettings pluginsettings.Service, orgService org.Service) error {
|
||||||
logger := log.New("provisioning.plugins")
|
logger := log.New("provisioning.plugins")
|
||||||
ap := PluginProvisioner{
|
ap := PluginProvisioner{
|
||||||
log: logger,
|
log: logger,
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/db"
|
"github.com/grafana/grafana/pkg/infra/db"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
plugifaces "github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/registry"
|
"github.com/grafana/grafana/pkg/registry"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/alerting"
|
"github.com/grafana/grafana/pkg/services/alerting"
|
||||||
@ -22,6 +21,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/notifications"
|
"github.com/grafana/grafana/pkg/services/notifications"
|
||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
prov_alerting "github.com/grafana/grafana/pkg/services/provisioning/alerting"
|
prov_alerting "github.com/grafana/grafana/pkg/services/provisioning/alerting"
|
||||||
"github.com/grafana/grafana/pkg/services/provisioning/dashboards"
|
"github.com/grafana/grafana/pkg/services/provisioning/dashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/provisioning/datasources"
|
"github.com/grafana/grafana/pkg/services/provisioning/datasources"
|
||||||
@ -37,7 +37,7 @@ func ProvideService(
|
|||||||
ac accesscontrol.AccessControl,
|
ac accesscontrol.AccessControl,
|
||||||
cfg *setting.Cfg,
|
cfg *setting.Cfg,
|
||||||
sqlStore db.DB,
|
sqlStore db.DB,
|
||||||
pluginStore plugifaces.Store,
|
pluginStore pluginstore.Store,
|
||||||
encryptionService encryption.Internal,
|
encryptionService encryption.Internal,
|
||||||
notificatonService *notifications.NotificationService,
|
notificatonService *notifications.NotificationService,
|
||||||
dashboardProvisioningService dashboardservice.DashboardProvisioningService,
|
dashboardProvisioningService dashboardservice.DashboardProvisioningService,
|
||||||
@ -108,7 +108,7 @@ func newProvisioningServiceImpl(
|
|||||||
newDashboardProvisioner dashboards.DashboardProvisionerFactory,
|
newDashboardProvisioner dashboards.DashboardProvisionerFactory,
|
||||||
provisionNotifiers func(context.Context, string, notifiers.Manager, org.Service, encryption.Internal, *notifications.NotificationService) error,
|
provisionNotifiers func(context.Context, string, notifiers.Manager, org.Service, encryption.Internal, *notifications.NotificationService) error,
|
||||||
provisionDatasources func(context.Context, string, datasources.Store, datasources.CorrelationsStore, org.Service) error,
|
provisionDatasources func(context.Context, string, datasources.Store, datasources.CorrelationsStore, org.Service) error,
|
||||||
provisionPlugins func(context.Context, string, plugifaces.Store, pluginsettings.Service, org.Service) error,
|
provisionPlugins func(context.Context, string, pluginstore.Store, pluginsettings.Service, org.Service) error,
|
||||||
) *ProvisioningServiceImpl {
|
) *ProvisioningServiceImpl {
|
||||||
return &ProvisioningServiceImpl{
|
return &ProvisioningServiceImpl{
|
||||||
log: log.New("provisioning"),
|
log: log.New("provisioning"),
|
||||||
@ -124,7 +124,7 @@ type ProvisioningServiceImpl struct {
|
|||||||
SQLStore db.DB
|
SQLStore db.DB
|
||||||
orgService org.Service
|
orgService org.Service
|
||||||
ac accesscontrol.AccessControl
|
ac accesscontrol.AccessControl
|
||||||
pluginStore plugifaces.Store
|
pluginStore pluginstore.Store
|
||||||
EncryptionService encryption.Internal
|
EncryptionService encryption.Internal
|
||||||
NotificationService *notifications.NotificationService
|
NotificationService *notifications.NotificationService
|
||||||
log log.Logger
|
log log.Logger
|
||||||
@ -133,7 +133,7 @@ type ProvisioningServiceImpl struct {
|
|||||||
dashboardProvisioner dashboards.DashboardProvisioner
|
dashboardProvisioner dashboards.DashboardProvisioner
|
||||||
provisionNotifiers func(context.Context, string, notifiers.Manager, org.Service, encryption.Internal, *notifications.NotificationService) error
|
provisionNotifiers func(context.Context, string, notifiers.Manager, org.Service, encryption.Internal, *notifications.NotificationService) error
|
||||||
provisionDatasources func(context.Context, string, datasources.Store, datasources.CorrelationsStore, org.Service) error
|
provisionDatasources func(context.Context, string, datasources.Store, datasources.CorrelationsStore, org.Service) error
|
||||||
provisionPlugins func(context.Context, string, plugifaces.Store, pluginsettings.Service, org.Service) error
|
provisionPlugins func(context.Context, string, pluginstore.Store, pluginsettings.Service, org.Service) error
|
||||||
provisionAlerting func(context.Context, prov_alerting.ProvisionerConfig) error
|
provisionAlerting func(context.Context, prov_alerting.ProvisionerConfig) error
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
dashboardProvisioningService dashboardservice.DashboardProvisioningService
|
dashboardProvisioningService dashboardservice.DashboardProvisioningService
|
||||||
|
@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/localcache"
|
"github.com/grafana/grafana/pkg/infra/localcache"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
pluginFakes "github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||||
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
|
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
|
||||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||||
@ -27,6 +26,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/publicdashboards"
|
"github.com/grafana/grafana/pkg/services/publicdashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/query"
|
"github.com/grafana/grafana/pkg/services/query"
|
||||||
fakeSecrets "github.com/grafana/grafana/pkg/services/secrets/fakes"
|
fakeSecrets "github.com/grafana/grafana/pkg/services/secrets/fakes"
|
||||||
@ -119,8 +119,8 @@ func buildQueryDataService(t *testing.T, cs datasources.CacheService, fpc *fakeP
|
|||||||
}
|
}
|
||||||
|
|
||||||
ds := &fakeDatasources.FakeDataSourceService{}
|
ds := &fakeDatasources.FakeDataSourceService{}
|
||||||
pCtxProvider := plugincontext.ProvideService(localcache.ProvideService(), &pluginFakes.FakePluginStore{
|
pCtxProvider := plugincontext.ProvideService(localcache.ProvideService(), &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "mysql",
|
ID: "mysql",
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/models/roletype"
|
"github.com/grafana/grafana/pkg/models/roletype"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
pluginFakes "github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||||
"github.com/grafana/grafana/pkg/services/contexthandler"
|
"github.com/grafana/grafana/pkg/services/contexthandler"
|
||||||
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
|
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
|
||||||
@ -34,6 +33,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
||||||
secretskvs "github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
secretskvs "github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
||||||
secretsmng "github.com/grafana/grafana/pkg/services/secrets/manager"
|
secretsmng "github.com/grafana/grafana/pkg/services/secrets/manager"
|
||||||
@ -468,8 +468,8 @@ func setup(t *testing.T) *testContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pCtxProvider := plugincontext.ProvideService(
|
pCtxProvider := plugincontext.ProvideService(
|
||||||
localcache.ProvideService(), &pluginFakes.FakePluginStore{
|
localcache.ProvideService(), &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{JSONData: plugins.JSONData{ID: "postgres"}},
|
{JSONData: plugins.JSONData{ID: "postgres"}},
|
||||||
{JSONData: plugins.JSONData{ID: "testdata"}},
|
{JSONData: plugins.JSONData{ID: "testdata"}},
|
||||||
{JSONData: plugins.JSONData{ID: "mysql"}},
|
{JSONData: plugins.JSONData{ID: "mysql"}},
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
pluginFakes "github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||||
"github.com/grafana/grafana/pkg/services/annotations/annotationstest"
|
"github.com/grafana/grafana/pkg/services/annotations/annotationstest"
|
||||||
"github.com/grafana/grafana/pkg/services/apikey"
|
"github.com/grafana/grafana/pkg/services/apikey"
|
||||||
@ -31,6 +30,7 @@ import (
|
|||||||
ngstore "github.com/grafana/grafana/pkg/services/ngalert/store"
|
ngstore "github.com/grafana/grafana/pkg/services/ngalert/store"
|
||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
"github.com/grafana/grafana/pkg/services/org/orgimpl"
|
"github.com/grafana/grafana/pkg/services/org/orgimpl"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/quota"
|
"github.com/grafana/grafana/pkg/services/quota"
|
||||||
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
||||||
@ -484,7 +484,7 @@ func setupEnv(t *testing.T, sqlStore *sqlstore.SQLStore, b bus.Bus, quotaService
|
|||||||
_, err = ngalert.ProvideService(
|
_, err = ngalert.ProvideService(
|
||||||
sqlStore.Cfg, featuremgmt.WithFeatures(), nil, nil, routing.NewRouteRegister(), sqlStore, nil, nil, nil, quotaService,
|
sqlStore.Cfg, featuremgmt.WithFeatures(), nil, nil, routing.NewRouteRegister(), sqlStore, nil, nil, nil, quotaService,
|
||||||
secretsService, nil, m, &foldertest.FakeService{}, &acmock.Mock{}, &dashboards.FakeDashboardService{}, nil, b, &acmock.Mock{},
|
secretsService, nil, m, &foldertest.FakeService{}, &acmock.Mock{}, &dashboards.FakeDashboardService{}, nil, b, &acmock.Mock{},
|
||||||
annotationstest.NewFakeAnnotationsRepo(), &pluginFakes.FakePluginStore{}, tracer, ruleStore,
|
annotationstest.NewFakeAnnotationsRepo(), &pluginstore.FakePluginStore{}, tracer, ruleStore,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, err = storesrv.ProvideService(sqlStore, featuremgmt.WithFeatures(), sqlStore.Cfg, quotaService, storesrv.ProvideSystemUsersService())
|
_, err = storesrv.ProvideService(sqlStore, featuremgmt.WithFeatures(), sqlStore.Cfg, quotaService, storesrv.ProvideSystemUsersService())
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/appcontext"
|
"github.com/grafana/grafana/pkg/infra/appcontext"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ type dsVal struct {
|
|||||||
|
|
||||||
type dsCache struct {
|
type dsCache struct {
|
||||||
ds datasources.DataSourceService
|
ds datasources.DataSourceService
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
cache map[int64]map[string]*dsVal
|
cache map[int64]map[string]*dsVal
|
||||||
timestamp time.Time // across all orgIDs
|
timestamp time.Time // across all orgIDs
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/store/entity"
|
"github.com/grafana/grafana/pkg/services/store/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ type EntityReferenceResolver interface {
|
|||||||
Resolve(ctx context.Context, ref *entity.EntityExternalReference) (ResolutionInfo, error)
|
Resolve(ctx context.Context, ref *entity.EntityExternalReference) (ResolutionInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideEntityReferenceResolver(ds datasources.DataSourceService, pluginStore plugins.Store) EntityReferenceResolver {
|
func ProvideEntityReferenceResolver(ds datasources.DataSourceService, pluginStore pluginstore.Store) EntityReferenceResolver {
|
||||||
return &standardReferenceResolver{
|
return &standardReferenceResolver{
|
||||||
pluginStore: pluginStore,
|
pluginStore: pluginStore,
|
||||||
ds: dsCache{
|
ds: dsCache{
|
||||||
@ -42,7 +43,7 @@ func ProvideEntityReferenceResolver(ds datasources.DataSourceService, pluginStor
|
|||||||
}
|
}
|
||||||
|
|
||||||
type standardReferenceResolver struct {
|
type standardReferenceResolver struct {
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
ds dsCache
|
ds dsCache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,10 +7,9 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/appcontext"
|
"github.com/grafana/grafana/pkg/infra/appcontext"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
fakeDatasources "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
fakeDatasources "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/store/entity"
|
"github.com/grafana/grafana/pkg/services/store/entity"
|
||||||
"github.com/grafana/grafana/pkg/services/user"
|
"github.com/grafana/grafana/pkg/services/user"
|
||||||
)
|
)
|
||||||
@ -37,15 +36,15 @@ func TestResolver(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p1 := plugins.PluginDTO{}
|
p1 := pluginstore.Plugin{}
|
||||||
p2 := plugins.PluginDTO{}
|
p2 := pluginstore.Plugin{}
|
||||||
p3 := plugins.PluginDTO{}
|
p3 := pluginstore.Plugin{}
|
||||||
|
|
||||||
p1.ID = "influx"
|
p1.ID = "influx"
|
||||||
p2.ID = "heatmap"
|
p2.ID = "heatmap"
|
||||||
p3.ID = "xyz"
|
p3.ID = "xyz"
|
||||||
pluginStore := &fakes.FakePluginStore{
|
pluginStore := &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{p1, p2, p3},
|
PluginList: []pluginstore.Plugin{p1, p2, p3},
|
||||||
}
|
}
|
||||||
provider := ProvideEntityReferenceResolver(ds, pluginStore)
|
provider := ProvideEntityReferenceResolver(ds, pluginStore)
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/supportbundles"
|
"github.com/grafana/grafana/pkg/services/supportbundles"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
@ -105,7 +106,7 @@ func settingsCollector(settings setting.Provider) supportbundles.Collector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func pluginInfoCollector(pluginStore plugins.Store, pluginSettings pluginsettings.Service, logger log.Logger) supportbundles.Collector {
|
func pluginInfoCollector(pluginStore pluginstore.Store, pluginSettings pluginsettings.Service, logger log.Logger) supportbundles.Collector {
|
||||||
return supportbundles.Collector{
|
return supportbundles.Collector{
|
||||||
UID: "plugins",
|
UID: "plugins",
|
||||||
DisplayName: "Plugin information",
|
DisplayName: "Plugin information",
|
||||||
|
@ -11,11 +11,11 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/kvstore"
|
"github.com/grafana/grafana/pkg/infra/kvstore"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/usagestats"
|
"github.com/grafana/grafana/pkg/infra/usagestats"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
|
||||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/supportbundles"
|
"github.com/grafana/grafana/pkg/services/supportbundles"
|
||||||
"github.com/grafana/grafana/pkg/services/supportbundles/bundleregistry"
|
"github.com/grafana/grafana/pkg/services/supportbundles/bundleregistry"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
@ -32,7 +32,7 @@ type Service struct {
|
|||||||
cfg *setting.Cfg
|
cfg *setting.Cfg
|
||||||
features *featuremgmt.FeatureManager
|
features *featuremgmt.FeatureManager
|
||||||
pluginSettings pluginsettings.Service
|
pluginSettings pluginsettings.Service
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
store bundleStore
|
store bundleStore
|
||||||
|
|
||||||
log log.Logger
|
log log.Logger
|
||||||
@ -51,7 +51,7 @@ func ProvideService(
|
|||||||
httpServer *grafanaApi.HTTPServer,
|
httpServer *grafanaApi.HTTPServer,
|
||||||
kvStore kvstore.KVStore,
|
kvStore kvstore.KVStore,
|
||||||
pluginSettings pluginsettings.Service,
|
pluginSettings pluginsettings.Service,
|
||||||
pluginStore plugins.Store,
|
pluginStore pluginstore.Store,
|
||||||
routeRegister routing.RouteRegister,
|
routeRegister routing.RouteRegister,
|
||||||
settings setting.Provider,
|
settings setting.Provider,
|
||||||
sql db.DB,
|
sql db.DB,
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/httpclient/httpclientprovider"
|
"github.com/grafana/grafana/pkg/infra/httpclient/httpclientprovider"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,14 +27,14 @@ type PluginsService struct {
|
|||||||
|
|
||||||
enabled bool
|
enabled bool
|
||||||
grafanaVersion string
|
grafanaVersion string
|
||||||
pluginStore plugins.Store
|
pluginStore pluginstore.Store
|
||||||
httpClient httpClient
|
httpClient httpClient
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
log log.Logger
|
log log.Logger
|
||||||
tracer tracing.Tracer
|
tracer tracing.Tracer
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvidePluginsService(cfg *setting.Cfg, pluginStore plugins.Store, tracer tracing.Tracer) (*PluginsService, error) {
|
func ProvidePluginsService(cfg *setting.Cfg, pluginStore pluginstore.Store, tracer tracing.Tracer) (*PluginsService, error) {
|
||||||
logger := log.New("plugins.update.checker")
|
logger := log.New("plugins.update.checker")
|
||||||
cl, err := httpclient.New(httpclient.Options{
|
cl, err := httpclient.New(httpclient.Options{
|
||||||
Middlewares: []httpclient.Middleware{
|
Middlewares: []httpclient.Middleware{
|
||||||
@ -180,7 +180,7 @@ func canUpdate(v1, v2 string) bool {
|
|||||||
return ver1.LessThan(ver2)
|
return ver1.LessThan(ver2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PluginsService) pluginIDsCSV(m map[string]plugins.PluginDTO) string {
|
func (s *PluginsService) pluginIDsCSV(m map[string]pluginstore.Plugin) string {
|
||||||
ids := make([]string, 0, len(m))
|
ids := make([]string, 0, len(m))
|
||||||
for pluginID := range m {
|
for pluginID := range m {
|
||||||
ids = append(ids, pluginID)
|
ids = append(ids, pluginID)
|
||||||
@ -189,8 +189,8 @@ func (s *PluginsService) pluginIDsCSV(m map[string]plugins.PluginDTO) string {
|
|||||||
return strings.Join(ids, ",")
|
return strings.Join(ids, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PluginsService) pluginsEligibleForVersionCheck(ctx context.Context) map[string]plugins.PluginDTO {
|
func (s *PluginsService) pluginsEligibleForVersionCheck(ctx context.Context) map[string]pluginstore.Plugin {
|
||||||
result := make(map[string]plugins.PluginDTO)
|
result := make(map[string]pluginstore.Plugin)
|
||||||
for _, p := range s.pluginStore.Plugins(ctx) {
|
for _, p := range s.pluginStore.Plugins(ctx) {
|
||||||
if p.IsCorePlugin() {
|
if p.IsCorePlugin() {
|
||||||
continue
|
continue
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPluginUpdateChecker_HasUpdate(t *testing.T) {
|
func TestPluginUpdateChecker_HasUpdate(t *testing.T) {
|
||||||
@ -21,8 +21,8 @@ func TestPluginUpdateChecker_HasUpdate(t *testing.T) {
|
|||||||
availableUpdates: map[string]string{
|
availableUpdates: map[string]string{
|
||||||
"test-ds": "1.0.0",
|
"test-ds": "1.0.0",
|
||||||
},
|
},
|
||||||
pluginStore: &fakes.FakePluginStore{
|
pluginStore: &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test-ds",
|
ID: "test-ds",
|
||||||
@ -44,8 +44,8 @@ func TestPluginUpdateChecker_HasUpdate(t *testing.T) {
|
|||||||
"test-panel": "0.9.0",
|
"test-panel": "0.9.0",
|
||||||
"test-app": "0.0.1",
|
"test-app": "0.0.1",
|
||||||
},
|
},
|
||||||
pluginStore: &fakes.FakePluginStore{
|
pluginStore: &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test-ds",
|
ID: "test-ds",
|
||||||
@ -86,8 +86,8 @@ func TestPluginUpdateChecker_HasUpdate(t *testing.T) {
|
|||||||
availableUpdates: map[string]string{
|
availableUpdates: map[string]string{
|
||||||
"test-panel": "0.9.0",
|
"test-panel": "0.9.0",
|
||||||
},
|
},
|
||||||
pluginStore: &fakes.FakePluginStore{
|
pluginStore: &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test-ds",
|
ID: "test-ds",
|
||||||
@ -129,8 +129,8 @@ func TestPluginUpdateChecker_checkForUpdates(t *testing.T) {
|
|||||||
availableUpdates: map[string]string{
|
availableUpdates: map[string]string{
|
||||||
"test-app": "1.0.0",
|
"test-app": "1.0.0",
|
||||||
},
|
},
|
||||||
pluginStore: &fakes.FakePluginStore{
|
pluginStore: &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{
|
PluginList: []pluginstore.Plugin{
|
||||||
{
|
{
|
||||||
JSONData: plugins.JSONData{
|
JSONData: plugins.JSONData{
|
||||||
ID: "test-ds",
|
ID: "test-ds",
|
||||||
|
@ -12,13 +12,13 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/infra/localcache"
|
"github.com/grafana/grafana/pkg/infra/localcache"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
pluginFakes "github.com/grafana/grafana/pkg/plugins/manager/fakes"
|
|
||||||
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||||
"github.com/grafana/grafana/pkg/services/datasources"
|
"github.com/grafana/grafana/pkg/services/datasources"
|
||||||
datasourceservice "github.com/grafana/grafana/pkg/services/datasources/service"
|
datasourceservice "github.com/grafana/grafana/pkg/services/datasources/service"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||||
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
||||||
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
||||||
secretskvs "github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
secretskvs "github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
||||||
@ -43,8 +43,8 @@ func TestHandleRequest(t *testing.T) {
|
|||||||
dsService, err := datasourceservice.ProvideService(nil, secretsService, secretsStore, sqlStore.Cfg, featuremgmt.WithFeatures(), acmock.New(), datasourcePermissions, quotaService)
|
dsService, err := datasourceservice.ProvideService(nil, secretsService, secretsStore, sqlStore.Cfg, featuremgmt.WithFeatures(), acmock.New(), datasourcePermissions, quotaService)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
pCtxProvider := plugincontext.ProvideService(localcache.ProvideService(), &pluginFakes.FakePluginStore{
|
pCtxProvider := plugincontext.ProvideService(localcache.ProvideService(), &pluginstore.FakePluginStore{
|
||||||
PluginList: []plugins.PluginDTO{{JSONData: plugins.JSONData{ID: "test"}}},
|
PluginList: []pluginstore.Plugin{{JSONData: plugins.JSONData{ID: "test"}}},
|
||||||
}, dsService, pluginSettings.ProvideService(sqlStore, secretsService))
|
}, dsService, pluginSettings.ProvideService(sqlStore, secretsService))
|
||||||
s := ProvideService(client, nil, dsService, pCtxProvider)
|
s := ProvideService(client, nil, dsService, pCtxProvider)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user