Alerting: Use URLs in image annotations (#66804)

* use tokens or urls in image annotations

* improve tests, fix some comments

* fix empty tokens

* code review changes, check for url before checking for token (support old token formats)
This commit is contained in:
Santiago
2023-04-26 13:06:18 -03:00
committed by GitHub
parent e1ab9cc9d8
commit b0881daf23
10 changed files with 146 additions and 35 deletions
+12
View File
@@ -49,6 +49,18 @@ func (s *FakeImageStore) GetImage(_ context.Context, token string) (*models.Imag
return nil, models.ErrImageNotFound
}
func (s *FakeImageStore) GetImageByURL(_ context.Context, url string) (*models.Image, error) {
s.mtx.Lock()
defer s.mtx.Unlock()
for _, image := range s.images {
if image.URL == url {
return image, nil
}
}
return nil, models.ErrImageNotFound
}
func (s *FakeImageStore) GetImages(_ context.Context, tokens []string) ([]models.Image, []string, error) {
s.mtx.Lock()
defer s.mtx.Unlock()