grafana/pkg/services/ngalert/notifier/images.go
Yuri Tseretyan f066e8cdcd
Alerting: Update to alerting 20230203015918-0e4e2675d7aa (after refactoring) (#62823)
* add alerting prefix to some packages from alerting that have similar names in prometheus alertmanager
2023-02-03 11:36:49 -05:00

41 lines
810 B
Go

package notifier
import (
"context"
"errors"
"github.com/grafana/alerting/images"
"github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/store"
)
type imageStore struct {
store store.ImageStore
}
func newImageStore(store store.ImageStore) images.ImageStore {
return &imageStore{
store: store,
}
}
func (i imageStore) GetImage(ctx context.Context, token string) (*images.Image, error) {
image, err := i.store.GetImage(ctx, token)
if err != nil {
if errors.Is(err, models.ErrImageNotFound) {
err = images.ErrImageNotFound
}
}
var result *images.Image
if image != nil {
result = &images.Image{
Token: image.Token,
Path: image.Path,
URL: image.URL,
CreatedAt: image.CreatedAt,
}
}
return result, err
}