Plugins: Remove pkg/infra/fs, pkg/infra/tracing and pkg/infra/process dependencies from pkg/plugins (#115798)

* remove dependency on packages

* update tests

* trigger
This commit is contained in:
Will Browne
2026-01-05 11:12:31 +00:00
committed by GitHub
parent 4e3039e4bd
commit 70b1053ad1
33 changed files with 131 additions and 134 deletions
@@ -1,20 +1,20 @@
package coreplugin_test
package coreplugin
import (
"context"
"testing"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/plugins/manager/pluginfakes"
"github.com/stretchr/testify/require"
)
func TestCorePlugin(t *testing.T) {
t.Run("New core plugin with empty opts should return expected values", func(t *testing.T) {
factory := coreplugin.New(backend.ServeOpts{})
factory := New(backend.ServeOpts{})
p, err := factory("plugin", log.New("test"), pluginfakes.InitializeNoopTracerForTest(), nil)
require.NoError(t, err)
require.NotNil(t, p)
@@ -36,7 +36,7 @@ func TestCorePlugin(t *testing.T) {
t.Run("New core plugin with handlers set in opts should return expected values", func(t *testing.T) {
checkHealthCalled := false
callResourceCalled := false
factory := coreplugin.New(backend.ServeOpts{
factory := New(backend.ServeOpts{
CheckHealthHandler: backend.CheckHealthHandlerFunc(func(ctx context.Context,
req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
checkHealthCalled = true
@@ -5,18 +5,16 @@ import (
"errors"
"fmt"
"go.opentelemetry.io/otel/trace"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
sdklog "github.com/grafana/grafana-plugin-sdk-go/backend/log"
sdktracing "github.com/grafana/grafana-plugin-sdk-go/backend/tracing"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"go.opentelemetry.io/otel/trace"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
cloudmonitoring "github.com/grafana/grafana/pkg/tsdb/cloud-monitoring"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch"
@@ -204,7 +202,7 @@ var ErrCorePluginNotFound = errors.New("core plugin not found")
// NewPlugin factory for creating and initializing a single core plugin.
// Note: cfg only needed for mssql connection pooling defaults.
func NewPlugin(pluginID string, cfg *setting.Cfg, httpClientProvider *httpclient.Provider, tracer trace.Tracer, features featuremgmt.FeatureToggles) (*plugins.Plugin, error) {
func NewPlugin(pluginID string, httpClientProvider *httpclient.Provider, tracer trace.Tracer) (*plugins.Plugin, error) {
jsonData := plugins.JSONData{
ID: pluginID,
AliasIDs: []string{},
@@ -241,7 +239,7 @@ func NewPlugin(pluginID string, cfg *setting.Cfg, httpClientProvider *httpclient
case MySQL:
svc = mysql.ProvideService()
case MSSQL:
svc = mssql.ProvideService(cfg)
svc = mssql.ProvideService()
case Pyroscope:
svc = pyroscope.ProvideService(httpClientProvider)
case Parca:
@@ -4,11 +4,10 @@ import (
"testing"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/plugins/tracing"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/setting"
"github.com/stretchr/testify/require"
)
func TestNewPlugin(t *testing.T) {
@@ -46,7 +45,7 @@ func TestNewPlugin(t *testing.T) {
tc.ExpectedID = tc.ID
}
p, err := NewPlugin(tc.ID, setting.NewCfg(), httpclient.NewProvider(), tracing.NoopTracer(), featuremgmt.WithFeatures())
p, err := NewPlugin(tc.ID, httpclient.NewProvider(), tracing.NoopTracer())
if tc.ExpectedNotFoundErr {
require.ErrorIs(t, err, ErrCorePluginNotFound)
require.Nil(t, p)