mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Add stored screenshot utilities to the channels package. (#49470)
Adds three functions: `withStoredImages` iterates over a list of models.Alerts, extracting a stored image's data from storage, if available, and executing a user-provided function. `withStoredImage` does this for an image attached to a specific alert. `openImage` finds and opens an image file on disk. Moves `store.Image` to `models.Image` Simplifies `channels.ImageStore` interface and updates notifiers that use it to use the simpler methods. Updates all pkg/alert/notifier/channels to use withStoredImage routines.
This commit is contained in:
@@ -21,9 +21,9 @@ type CountingImageService struct {
|
||||
Called int
|
||||
}
|
||||
|
||||
func (c *CountingImageService) NewImage(_ context.Context, _ *ngmodels.AlertRule) (*store.Image, error) {
|
||||
func (c *CountingImageService) NewImage(_ context.Context, _ *ngmodels.AlertRule) (*ngmodels.Image, error) {
|
||||
c.Called += 1
|
||||
return &store.Image{
|
||||
return &ngmodels.Image{
|
||||
Token: fmt.Sprint(rand.Int()),
|
||||
}, nil
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func Test_maybeNewImage(t *testing.T) {
|
||||
true,
|
||||
&State{
|
||||
State: eval.Alerting,
|
||||
Image: &store.Image{
|
||||
Image: &ngmodels.Image{
|
||||
Token: "erase me",
|
||||
},
|
||||
},
|
||||
@@ -60,7 +60,7 @@ func Test_maybeNewImage(t *testing.T) {
|
||||
&State{
|
||||
Resolved: true,
|
||||
State: eval.Normal,
|
||||
Image: &store.Image{
|
||||
Image: &ngmodels.Image{
|
||||
Token: "abcd",
|
||||
},
|
||||
},
|
||||
@@ -71,7 +71,7 @@ func Test_maybeNewImage(t *testing.T) {
|
||||
false,
|
||||
&State{
|
||||
State: eval.Alerting,
|
||||
Image: &store.Image{
|
||||
Image: &ngmodels.Image{
|
||||
Token: "already set",
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user