Fix circular imports

This commit is contained in:
Giuseppe Guerra
2023-06-21 10:08:27 +02:00
parent c11cff2107
commit df35cc0bfb
2 changed files with 5 additions and 15 deletions
+1 -12
View File
@@ -6,8 +6,8 @@ import (
"time"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/services/pluginsintegration/angulardetectorsprovider"
)
// Store is the publicly accessible storage for plugins.
@@ -182,14 +182,3 @@ type KeyStore interface {
type KeyRetriever interface {
GetPublicKey(ctx context.Context, keyID string) (string, error)
}
type AngularPatternsStore interface {
// TODO: move GCOMPatterns into another package
Get(ctx context.Context) (angulardetectorsprovider.GCOMPatterns, error)
Set(ctx context.Context, patterns angulardetectorsprovider.GCOMPatterns) error
GetLastUpdated(ctx context.Context) (time.Time, error)
}
/*type AngularDetectorsProvider interface {
ProvideDetectors(ctx context.Context) []angulardetector.Detector
}*/
@@ -7,6 +7,7 @@ import (
"time"
"github.com/grafana/grafana/pkg/infra/kvstore"
"github.com/grafana/grafana/pkg/services/pluginsintegration/angulardetectorsprovider"
)
const (
@@ -24,7 +25,7 @@ func ProvideService(kv kvstore.KVStore) *Service {
}
}
func (s *Service) Get(ctx context.Context) ([]map[string]string, error) {
func (s *Service) Get(ctx context.Context) (angulardetectorsprovider.GCOMPatterns, error) {
data, ok, err := s.kv.Get(ctx, keyPatterns)
if err != nil {
return nil, fmt.Errorf("kv get: %w", err)
@@ -32,7 +33,7 @@ func (s *Service) Get(ctx context.Context) ([]map[string]string, error) {
if !ok {
return nil, nil
}
var out map[string]string
var out angulardetectorsprovider.GCOMPatterns
if err := json.Unmarshal([]byte(data), &out); err != nil {
// Ignore decode errors, so we can change the format in future versions
// and keep backwards/forwards compatibility
@@ -42,7 +43,7 @@ func (s *Service) Get(ctx context.Context) ([]map[string]string, error) {
}
func (s *Service) Set(ctx context.Context, patterns []map[string]string) error {
func (s *Service) Set(ctx context.Context, patterns angulardetectorsprovider.GCOMPatterns) error {
b, err := json.Marshal(patterns)
if err != nil {
return fmt.Errorf("json marshal: %w", err)