mirror of https://github.com/grafana/grafana
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.pull/48114/head^2
parent
33d4850c90
commit
9e8efaa459
@ -1,53 +0,0 @@ |
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/grafana/grafana/pkg/services/ngalert/image (interfaces: ImageService)
|
||||
|
||||
// Package image is a generated GoMock package.
|
||||
package image |
||||
|
||||
import ( |
||||
context "context" |
||||
reflect "reflect" |
||||
|
||||
gomock "github.com/golang/mock/gomock" |
||||
data "github.com/grafana/grafana-plugin-sdk-go/data" |
||||
models "github.com/grafana/grafana/pkg/services/ngalert/models" |
||||
store "github.com/grafana/grafana/pkg/services/ngalert/store" |
||||
) |
||||
|
||||
// MockImageService is a mock of ImageService interface.
|
||||
type MockImageService struct { |
||||
ctrl *gomock.Controller |
||||
recorder *MockImageServiceMockRecorder |
||||
} |
||||
|
||||
// MockImageServiceMockRecorder is the mock recorder for MockImageService.
|
||||
type MockImageServiceMockRecorder struct { |
||||
mock *MockImageService |
||||
} |
||||
|
||||
// NewMockImageService creates a new mock instance.
|
||||
func NewMockImageService(ctrl *gomock.Controller) *MockImageService { |
||||
mock := &MockImageService{ctrl: ctrl} |
||||
mock.recorder = &MockImageServiceMockRecorder{mock} |
||||
return mock |
||||
} |
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockImageService) EXPECT() *MockImageServiceMockRecorder { |
||||
return m.recorder |
||||
} |
||||
|
||||
// NewImage mocks base method.
|
||||
func (m *MockImageService) NewImage(arg0 context.Context, arg1 *models.AlertRule, arg2 data.Labels) (*store.Image, error) { |
||||
m.ctrl.T.Helper() |
||||
ret := m.ctrl.Call(m, "NewImage", arg0, arg1, arg2) |
||||
ret0, _ := ret[0].(*store.Image) |
||||
ret1, _ := ret[1].(error) |
||||
return ret0, ret1 |
||||
} |
||||
|
||||
// NewImage indicates an expected call of NewImage.
|
||||
func (mr *MockImageServiceMockRecorder) NewImage(arg0, arg1, arg2 interface{}) *gomock.Call { |
||||
mr.mock.ctrl.T.Helper() |
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewImage", reflect.TypeOf((*MockImageService)(nil).NewImage), arg0, arg1, arg2) |
||||
} |
@ -0,0 +1,23 @@ |
||||
package models |
||||
|
||||
import ( |
||||
"errors" |
||||
"time" |
||||
) |
||||
|
||||
// ErrImageNotFound is returned when the image does not exist.
|
||||
var ErrImageNotFound = errors.New("image not found") |
||||
|
||||
type Image struct { |
||||
ID int64 `xorm:"pk autoincr 'id'"` |
||||
Token string `xorm:"token"` |
||||
Path string `xorm:"path"` |
||||
URL string `xorm:"url"` |
||||
CreatedAt time.Time `xorm:"created_at"` |
||||
ExpiresAt time.Time `xorm:"expires_at"` |
||||
} |
||||
|
||||
// A XORM interface that defines the used table for this struct.
|
||||
func (i *Image) TableName() string { |
||||
return "alert_image" |
||||
} |
Loading…
Reference in new issue