mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
f066e8cdcd
* add alerting prefix to some packages from alerting that have similar names in prometheus alertmanager
41 lines
810 B
Go
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
|
|
}
|