Documentation ¶
Overview ¶
Package notifier contains implementations for writing notifications to arbitrary sources based on inbound events.
Index ¶
Constants ¶
const ( // NotificationColourRed is used to set a notification's colour to red. NotificationColourRed = NotificationColour("red") )
Variables ¶
var ErrDiscordAPI = errors.New("error from discord API")
ErrDiscordAPI is a general error returned when a non 200 response has been returned from the discord API.
var ErrSlackAPI = errors.New("error from slack API")
ErrSlackAPI is a general error returned when a non 200 response has been returned from the slack API.
Functions ¶
This section is empty.
Types ¶
type DiscordNotifier ¶
type DiscordNotifier struct {
// contains filtered or unexported fields
}
The DiscordNotifier type is a Notifier implementation that writes notifications to a discord channel via a webhook URL.
func NewDiscordNotifier ¶
func NewDiscordNotifier(webhookURL string) *DiscordNotifier
NewDiscordNotifier returns a new instance of the DiscordNotifier type that will send notifications to the specified webhook.
func (*DiscordNotifier) Notify ¶
func (dn *DiscordNotifier) Notify(ctx context.Context, opts NotifyOptions) error
Notify a discord channel based on the NotifyOptions.
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
The EventHandler type is responsible for handling inbound events and producing notifications when applicable.
func NewEventHandler ¶
func NewEventHandler(reader EventReader, notifier Notifier) *EventHandler
NewEventHandler returns a new instance of the EventHandler type that will read events from the given EventHandler information and produce notifications via the Notifier implementation where applicable. Currently, this is used to produce policy failure notifications.
type EventReader ¶
The EventReader interface describes types that can read events from an arbitrary event stream.
type NotificationColour ¶
type NotificationColour string
The NotificationColour type is an enum used to pass a desired colour to Notifier implementations so they can set their provider specific colours.
type Notifier ¶
type Notifier interface {
Notify(ctx context.Context, opts NotifyOptions) error
}
The Notifier interface describes types that send notifications to an arbitrary receiver based on the NotifyOptions.
type NotifyOptions ¶
type NotifyOptions struct { Title string Message string Data map[string]interface{} Colour NotificationColour }
The NotifyOptions type contains all options passed to a Notifier that can be used to construct notifications.
type SlackNotifier ¶
type SlackNotifier struct {
// contains filtered or unexported fields
}
The SlackNotifier type is a Notifier implementation that writes notifications to a slack channel via a webhook URL.
func NewSlackNotifier ¶
func NewSlackNotifier(webhookURL string) *SlackNotifier
NewSlackNotifier returns a new instance of the SlackNotifier type that will send notifications to the specified webhook.
func (*SlackNotifier) Notify ¶
func (sn *SlackNotifier) Notify(ctx context.Context, opts NotifyOptions) error
Notify a slack channel based on the NotifyOptions.