Alerting: Bump grafana/alerting and refactor the ImageStore/Provider to provide image URL/bytes (#70182)
* implement alerting.images.Provider interface in our ImageStore * add URLExists() method to fakeConfigStore * make linter happy * update integration tests
This commit is contained in:
@@ -9,10 +9,15 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
)
|
||||
|
||||
func NewFakeImageStore(t *testing.T) *FakeImageStore {
|
||||
func NewFakeImageStore(t *testing.T, images ...*models.Image) *FakeImageStore {
|
||||
imageMap := make(map[string]*models.Image)
|
||||
for _, image := range images {
|
||||
imageMap[image.Token] = image
|
||||
}
|
||||
|
||||
return &FakeImageStore{
|
||||
t: t,
|
||||
images: make(map[string]*models.Image),
|
||||
images: imageMap,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +48,17 @@ func (s *FakeImageStore) GetImageByURL(_ context.Context, url string) (*models.I
|
||||
return nil, models.ErrImageNotFound
|
||||
}
|
||||
|
||||
func (s *FakeImageStore) URLExists(_ context.Context, url string) (bool, error) {
|
||||
s.mtx.Lock()
|
||||
defer s.mtx.Unlock()
|
||||
for _, image := range s.images {
|
||||
if image.URL == url {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (s *FakeImageStore) GetImages(_ context.Context, tokens []string) ([]models.Image, []string, error) {
|
||||
s.mtx.Lock()
|
||||
defer s.mtx.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user