wwalert

package
v0.22.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendMsTeams

func SendMsTeams(ctx context.Context, webhookUrl string, message MsTeamsMessagePayload) error

Types

type AlertsConfig

type AlertsConfig struct {
	Default    CategoryConfig            `yaml:"default"`
	Categories map[string]CategoryConfig `yaml:"categories"`
}

func ReadConfig

func ReadConfig(filePath string) (*AlertsConfig, error)

type AwsSecret

type AwsSecret struct {
	Id   string `json:"id"`
	Prop string `json:"prop"`
}

func (AwsSecret) Resolve

func (s AwsSecret) Resolve(ctx context.Context) (string, error)

type CategoryConfig

type CategoryConfig struct {
	Slack   []SlackAlertConfig   `yaml:"slack"`
	MsTeams []MsTeamsAlertConfig `yaml:"ms_teams"`
}

type ConfigAlerter

type ConfigAlerter struct {
	// contains filtered or unexported fields
}

func NewConfigAlerter

func NewConfigAlerter(log zerolog.Logger, config *AlertsConfig, appName string) *ConfigAlerter

func NewConfigAlerterFromEnv

func NewConfigAlerterFromEnv(log zerolog.Logger, appName string) (*ConfigAlerter, error)

func (*ConfigAlerter) SendAlert

func (a *ConfigAlerter) SendAlert(ctx context.Context, category string, msg string) error

type MsTeamsAlertConfig

type MsTeamsAlertConfig struct {
	// Required if WebhookAwsSecret is not set.
	Webhook string `yaml:"webhook"`
	// Required if Webhook is not set, otherwise ignored.
	WebhookAwsSecret *AwsSecret `yaml:"webhook_aws_secret"`
	// Optional
	Prefix string
}

type MsTeamsAlerter

type MsTeamsAlerter struct {
	Log           zerolog.Logger
	Configs       []MsTeamsAlertConfig
	DefaultPrefix string
}

func (MsTeamsAlerter) SendAlert

func (sa MsTeamsAlerter) SendAlert(ctx context.Context, msg string) error

type MsTeamsMessagePayload

type MsTeamsMessagePayload struct {
	Text string `json:"text"`
}

type SlackAlertConfig

type SlackAlertConfig struct {
	// Required if WebhookAwsSecret is not set.
	Webhook string `yaml:"webhook"`
	// Required if Webhook is not set, otherwise ignored.
	WebhookAwsSecret *AwsSecret `yaml:"webhook_aws_secret"`
	// Optional.
	Channel string `yaml:"channel"`
	// Optional.
	Username string `yaml:"username"`
	// Optional.
	IconEmoji string `yaml:"icon_emoji"`
}

type SlackAlerter

type SlackAlerter struct {
	Log             zerolog.Logger
	Configs         []SlackAlertConfig
	DefaultUsername string
}

func (SlackAlerter) SendAlert

func (sa SlackAlerter) SendAlert(ctx context.Context, msg string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL