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
+10 -4
View File
@@ -13,6 +13,8 @@ import (
"github.com/grafana/grafana/pkg/infra/kvstore"
"github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/store"
alertingImages "github.com/grafana/alerting/images"
)
type fakeConfigStore struct {
@@ -24,19 +26,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 {