Plugins: Refactor plugin config into separate env var and request scoped services (#83261)
* seperate services for env + req * merge with main * fix tests * undo changes to golden file * fix linter * remove unused fields * split out new config struct * provide config * undo go mod changes * more renaming * fix tests * undo bra.toml changes * update go.work.sum * undo changes * trigger * apply PR feedback
This commit is contained in:
@@ -18,7 +18,7 @@ import (
|
||||
func TestQueryData(t *testing.T) {
|
||||
t.Run("Empty registry should return not registered error", func(t *testing.T) {
|
||||
registry := fakes.NewFakePluginRegistry()
|
||||
client := ProvideService(registry, &config.Cfg{})
|
||||
client := ProvideService(registry, &config.PluginManagementCfg{})
|
||||
_, err := client.QueryData(context.Background(), &backend.QueryDataRequest{})
|
||||
require.Error(t, err)
|
||||
require.ErrorIs(t, err, plugins.ErrPluginNotRegistered)
|
||||
@@ -63,7 +63,7 @@ func TestQueryData(t *testing.T) {
|
||||
err := registry.Add(context.Background(), p)
|
||||
require.NoError(t, err)
|
||||
|
||||
client := ProvideService(registry, &config.Cfg{})
|
||||
client := ProvideService(registry, &config.PluginManagementCfg{})
|
||||
_, err = client.QueryData(context.Background(), &backend.QueryDataRequest{
|
||||
PluginContext: backend.PluginContext{
|
||||
PluginID: "grafana",
|
||||
@@ -79,7 +79,7 @@ func TestQueryData(t *testing.T) {
|
||||
func TestCheckHealth(t *testing.T) {
|
||||
t.Run("empty plugin registry should return plugin not registered error", func(t *testing.T) {
|
||||
registry := fakes.NewFakePluginRegistry()
|
||||
client := ProvideService(registry, &config.Cfg{})
|
||||
client := ProvideService(registry, &config.PluginManagementCfg{})
|
||||
_, err := client.CheckHealth(context.Background(), &backend.CheckHealthRequest{})
|
||||
require.Error(t, err)
|
||||
require.ErrorIs(t, err, plugins.ErrPluginNotRegistered)
|
||||
@@ -125,7 +125,7 @@ func TestCheckHealth(t *testing.T) {
|
||||
err := registry.Add(context.Background(), p)
|
||||
require.NoError(t, err)
|
||||
|
||||
client := ProvideService(registry, &config.Cfg{})
|
||||
client := ProvideService(registry, &config.PluginManagementCfg{})
|
||||
_, err = client.CheckHealth(context.Background(), &backend.CheckHealthRequest{
|
||||
PluginContext: backend.PluginContext{
|
||||
PluginID: "grafana",
|
||||
@@ -189,7 +189,7 @@ func TestCallResource(t *testing.T) {
|
||||
err := registry.Add(context.Background(), p)
|
||||
require.NoError(t, err)
|
||||
|
||||
client := ProvideService(registry, &config.Cfg{})
|
||||
client := ProvideService(registry, &config.PluginManagementCfg{})
|
||||
|
||||
err = client.CallResource(context.Background(), req, sender)
|
||||
require.NoError(t, err)
|
||||
@@ -252,7 +252,7 @@ func TestCallResource(t *testing.T) {
|
||||
err := registry.Add(context.Background(), p)
|
||||
require.NoError(t, err)
|
||||
|
||||
client := ProvideService(registry, &config.Cfg{})
|
||||
client := ProvideService(registry, &config.PluginManagementCfg{})
|
||||
|
||||
err = client.CallResource(context.Background(), req, sender)
|
||||
require.NoError(t, err)
|
||||
@@ -298,7 +298,7 @@ func TestCallResource(t *testing.T) {
|
||||
err := registry.Add(context.Background(), p)
|
||||
require.NoError(t, err)
|
||||
|
||||
client := ProvideService(registry, &config.Cfg{})
|
||||
client := ProvideService(registry, &config.PluginManagementCfg{})
|
||||
|
||||
err = client.CallResource(context.Background(), req, sender)
|
||||
require.NoError(t, err)
|
||||
@@ -366,7 +366,7 @@ func TestCallResource(t *testing.T) {
|
||||
err := registry.Add(context.Background(), p)
|
||||
require.NoError(t, err)
|
||||
|
||||
client := ProvideService(registry, &config.Cfg{})
|
||||
client := ProvideService(registry, &config.PluginManagementCfg{})
|
||||
|
||||
err = client.CallResource(context.Background(), req, sender)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user