Chore: Remove plugincontext.ErrPluginNotFound (#74997)

This commit is contained in:
Andres Martinez Gotor
2023-09-25 13:10:47 +03:00
committed by GitHub
parent 1714fa598c
commit ece94b1e01
9 changed files with 18 additions and 32 deletions
+3 -3
View File
@@ -7,11 +7,11 @@ import (
"github.com/centrifugal/centrifuge"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/auth/identity"
"github.com/grafana/grafana/pkg/services/live/model"
"github.com/grafana/grafana/pkg/services/live/orgchannel"
"github.com/grafana/grafana/pkg/services/live/runstream"
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
)
//go:generate mockgen -destination=plugin_mock.go -package=features github.com/grafana/grafana/pkg/services/live/features PluginContextGetter
@@ -66,7 +66,7 @@ type PluginPathRunner struct {
func (r *PluginPathRunner) OnSubscribe(ctx context.Context, user identity.Requester, e model.SubscribeEvent) (model.SubscribeReply, backend.SubscribeStreamStatus, error) {
pCtx, err := r.pluginContextGetter.GetPluginContext(ctx, user, r.pluginID, r.datasourceUID, false)
if err != nil {
if errors.Is(err, plugincontext.ErrPluginNotFound) {
if errors.Is(err, plugins.ErrPluginNotRegistered) {
logger.Error("Plugin context not found", "path", r.path)
return model.SubscribeReply{}, 0, centrifuge.ErrorInternal
}
@@ -110,7 +110,7 @@ func (r *PluginPathRunner) OnSubscribe(ctx context.Context, user identity.Reques
func (r *PluginPathRunner) OnPublish(ctx context.Context, user identity.Requester, e model.PublishEvent) (model.PublishReply, backend.PublishStreamStatus, error) {
pCtx, err := r.pluginContextGetter.GetPluginContext(ctx, user, r.pluginID, r.datasourceUID, false)
if err != nil {
if errors.Is(err, plugincontext.ErrPluginNotFound) {
if errors.Is(err, plugins.ErrPluginNotRegistered) {
logger.Error("Plugin context not found", "path", r.path)
return model.PublishReply{}, 0, centrifuge.ErrorInternal
}
+4 -4
View File
@@ -11,8 +11,8 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/auth/identity"
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
)
var (
@@ -185,7 +185,7 @@ func (s *Manager) watchStream(ctx context.Context, cancelFn func(), sr streamReq
dsUID := sr.PluginContext.DataSourceInstanceSettings.UID
pCtx, err := s.pluginContextGetter.GetPluginContext(ctx, sr.user, sr.PluginContext.PluginID, dsUID, false)
if err != nil {
if errors.Is(err, plugincontext.ErrPluginNotFound) {
if errors.Is(err, plugins.ErrPluginNotRegistered) {
logger.Debug("Datasource not found, stop stream", "channel", sr.Channel, "path", sr.Path)
return
}
@@ -286,7 +286,7 @@ func (s *Manager) runStream(ctx context.Context, cancelFn func(), sr streamReque
}
newPluginCtx, err := s.pluginContextGetter.GetPluginContext(ctx, sr.user, pluginCtx.PluginID, datasourceUID, false)
if err != nil {
if errors.Is(err, plugincontext.ErrPluginNotFound) {
if errors.Is(err, plugins.ErrPluginNotRegistered) {
logger.Info("No plugin context found, stopping stream", "path", sr.Path)
return
}
@@ -410,7 +410,7 @@ func (s *Manager) SubmitStream(ctx context.Context, user identity.Requester, cha
}
newPluginCtx, err := s.pluginContextGetter.GetPluginContext(ctx, user, pCtx.PluginID, datasourceUID, false)
if err != nil {
if errors.Is(err, plugincontext.ErrPluginNotFound) {
if errors.Is(err, plugins.ErrPluginNotRegistered) {
return nil, errDatasourceNotFound
}
return nil, err
@@ -29,8 +29,6 @@ const (
pluginSettingsCachePrefix = "plugin-setting-"
)
var ErrPluginNotFound = errors.New("plugin not found")
func ProvideService(cfg *setting.Cfg, cacheService *localcache.CacheService, pluginStore pluginstore.Store,
dataSourceService datasources.DataSourceService, pluginSettingsService pluginsettings.Service,
licensing plugins.Licensing, pCfg *config.Cfg) *Provider {
@@ -62,7 +60,7 @@ type Provider struct {
func (p *Provider) Get(ctx context.Context, pluginID string, user identity.Requester, orgID int64) (backend.PluginContext, error) {
plugin, exists := p.pluginStore.Plugin(ctx, pluginID)
if !exists {
return backend.PluginContext{}, ErrPluginNotFound
return backend.PluginContext{}, plugins.ErrPluginNotRegistered
}
pCtx := backend.PluginContext{
@@ -97,7 +95,7 @@ func (p *Provider) Get(ctx context.Context, pluginID string, user identity.Reque
func (p *Provider) GetWithDataSource(ctx context.Context, pluginID string, user identity.Requester, ds *datasources.DataSource) (backend.PluginContext, error) {
plugin, exists := p.pluginStore.Plugin(ctx, pluginID)
if !exists {
return backend.PluginContext{}, ErrPluginNotFound
return backend.PluginContext{}, plugins.ErrPluginNotRegistered
}
pCtx := backend.PluginContext{