grafana/pkg/services/pluginsintegration/loader/fakes.go
Will Browne 72da44db0e
Plugins: Add validation stage to plugin loader pipeline (#73053)
* first pass

* change validation signature

* err tracking

* fix

* undo golden

* 1 more

* fix

* adjust doc

* add test helper

* fix linter
2023-08-09 18:25:28 +02:00

39 lines
944 B
Go

package loader
import (
"context"
"github.com/grafana/grafana/pkg/plugins"
)
type fakeSignatureErrorTracker struct {
RecordFunc func(ctx context.Context, err *plugins.SignatureError)
ClearFunc func(ctx context.Context, pluginID string)
SignatureErrorsFunc func(ctx context.Context) []*plugins.SignatureError
}
func newFakeSignatureErrorTracker() *fakeSignatureErrorTracker {
return &fakeSignatureErrorTracker{}
}
func (t *fakeSignatureErrorTracker) Record(ctx context.Context, err *plugins.SignatureError) {
if t.RecordFunc != nil {
t.RecordFunc(ctx, err)
return
}
}
func (t *fakeSignatureErrorTracker) Clear(ctx context.Context, pluginID string) {
if t.ClearFunc != nil {
t.ClearFunc(ctx, pluginID)
return
}
}
func (t *fakeSignatureErrorTracker) SignatureErrors(ctx context.Context) []*plugins.SignatureError {
if t.SignatureErrorsFunc != nil {
return t.SignatureErrorsFunc(ctx)
}
return nil
}