Frontend Sandbox: Add to statscollector (#99735)

This commit is contained in:
Andres Martinez Gotor
2025-01-30 16:17:36 +01:00
committed by GitHub
parent 64e9c38b66
commit a066659e11
5 changed files with 62 additions and 0 deletions
@@ -0,0 +1,21 @@
package sandbox
import "github.com/grafana/grafana/pkg/setting"
type Sandbox interface {
Plugins() ([]string, error)
}
type Service struct {
cfg *setting.Cfg
}
func ProvideService(cfg *setting.Cfg) *Service {
return &Service{
cfg: cfg,
}
}
func (s *Service) Plugins() ([]string, error) {
return s.cfg.EnableFrontendSandboxForPlugins, nil
}
@@ -0,0 +1,19 @@
package sandbox
import (
"testing"
"github.com/grafana/grafana/pkg/setting"
"github.com/stretchr/testify/assert"
)
func TestService_Plugins(t *testing.T) {
cfg := &setting.Cfg{
EnableFrontendSandboxForPlugins: []string{"plugin1", "plugin2"},
}
service := ProvideService(cfg)
plugins, err := service.Plugins()
assert.NoError(t, err)
assert.Equal(t, []string{"plugin1", "plugin2"}, plugins)
}