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:
Santiago
2023-06-21 20:53:30 -03:00
committed by GitHub
parent 3007e3b209
commit ff9eff49bd
11 changed files with 388 additions and 59 deletions
+18 -2
View File
@@ -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()