grafana/pkg/services/ngalert/models/image.go
Joe Blubaugh 9e8efaa459
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.
2022-05-26 13:29:56 +08:00

24 lines
546 B
Go

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"
}