Alerting: Refactor the ImageStore/Provider to provide image URL/bytes (#67693)

* (WIP) Refactor the ImageStore interface to work with our latest alerting repository

* update alerting package

* refactor, new URLExists method in ImageProvider

* tests for the new methods

* fix linter warnings

* use alertingImages as an alias for grafana/alerting/images

* logs about image uris and not found images

* nerf image not found logs

* extract duplicated code to getImageFromURI() method

* refactor getImageFromURI()

* add index on url

* add comment about migration log

* sync generated files
This commit is contained in:
Santiago
2023-05-30 11:25:55 -03:00
committed by GitHub
parent ce0c1f0b0b
commit 72a187b0be
10 changed files with 365 additions and 31 deletions
+9 -4
View File
@@ -10,6 +10,7 @@ import (
"testing"
"time"
alertingImages "github.com/grafana/alerting/images"
"github.com/grafana/grafana/pkg/infra/kvstore"
"github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/store"
@@ -24,19 +25,23 @@ type fakeConfigStore struct {
// Saves the image or returns an error.
func (f *fakeConfigStore) SaveImage(ctx context.Context, img *models.Image) error {
return models.ErrImageNotFound
return alertingImages.ErrImageNotFound
}
func (f *fakeConfigStore) GetImage(ctx context.Context, token string) (*models.Image, error) {
return nil, models.ErrImageNotFound
return nil, alertingImages.ErrImageNotFound
}
func (f *fakeConfigStore) GetImageByURL(ctx context.Context, url string) (*models.Image, error) {
return nil, models.ErrImageNotFound
return nil, alertingImages.ErrImageNotFound
}
func (f *fakeConfigStore) URLExists(ctx context.Context, url string) (bool, error) {
return false, alertingImages.ErrImageNotFound
}
func (f *fakeConfigStore) GetImages(ctx context.Context, tokens []string) ([]models.Image, []string, error) {
return nil, nil, models.ErrImageNotFound
return nil, nil, alertingImages.ErrImageNotFound
}
func NewFakeConfigStore(t *testing.T, configs map[int64]*models.AlertConfiguration) *fakeConfigStore {