notifications

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAutoHealNotificationMessage

func BuildAutoHealNotificationMessage(format MessageFormat, environmentName, containerName string) string

func BuildBatchImageUpdateNotificationMessage

func BuildBatchImageUpdateNotificationMessage(format MessageFormat, environmentName string, updates map[string]*imageupdate.Response) string

func BuildContainerUpdateNotificationMessage

func BuildContainerUpdateNotificationMessage(format MessageFormat, environmentName, containerName, imageRef, oldDigest, newDigest string) string

func BuildDiscordURL

func BuildDiscordURL(config DiscordConfig) (string, error)

BuildDiscordURL converts DiscordConfig to Shoutrrr URL format using shoutrrr's Config

func BuildEmailSubject

func BuildEmailSubject(environmentName, subject string) string

func BuildGenericURL

func BuildGenericURL(config GenericConfig) (string, error)

BuildGenericURL converts GenericConfig to Shoutrrr URL format for generic webhooks

func BuildGoogleChatURL added in v2.7.0

func BuildGoogleChatURL(config GoogleChatConfig) (string, error)

BuildGoogleChatURL converts GoogleChatConfig to Shoutrrr URL format by swapping the incoming webhook URL's scheme to googlechat while preserving the host, path and the key/token query parameters.

func BuildGotifyURL

func BuildGotifyURL(config GotifyConfig) (string, error)

BuildGotifyURL converts GotifyConfig to Shoutrrr URL format URL example: gotify://host[:port][/path]/token[?query]

func BuildImageUpdateNotificationMessage

func BuildImageUpdateNotificationMessage(format MessageFormat, environmentName, imageRef string, updateInfo *imageupdate.Response) string

func BuildMatrixURL

func BuildMatrixURL(config MatrixConfig) (string, error)

BuildMatrixURL converts MatrixConfig to Shoutrrr URL format URL example: matrix://user:password@host[:port]/[?rooms=!roomID1[,roomAlias2]][&disableTLS=yes]

func BuildNtfyURL

func BuildNtfyURL(config NtfyConfig) (string, error)

BuildNtfyURL converts NtfyConfig to Shoutrrr URL format URL example: ntfy://[user:password@]host[:port]/topic[?query]

func BuildPruneReportNotificationMessage

func BuildPruneReportNotificationMessage(format MessageFormat, environmentName string, result *system.PruneAllResult) string

func BuildPushoverURL

func BuildPushoverURL(config PushoverConfig) (string, error)

BuildPushoverURL converts PushoverConfig to Shoutrrr URL format. URL example: pushover://:token@user?devices=device1,device2&priority=1&title=Container+Update

func BuildSignalURL

func BuildSignalURL(config SignalConfig) (string, error)

BuildSignalURL converts SignalConfig to Shoutrrr URL format using shoutrrr's Config

func BuildSlackURL

func BuildSlackURL(config SlackConfig) (string, error)

BuildSlackURL converts SlackConfig to Shoutrrr URL format using shoutrrr's Config

func BuildTelegramURL

func BuildTelegramURL(config TelegramConfig) (string, error)

BuildTelegramURL converts TelegramConfig to Shoutrrr URL format using shoutrrr's Config

func BuildVulnerabilitySummaryNotificationMessage

func BuildVulnerabilitySummaryNotificationMessage(format MessageFormat, environmentName, summaryLabel, overview, fixableCount, severityBreakdown, sampleCVEs string) string

func DecodeConfig added in v2.1.0

func DecodeConfig[T any](config database.JSON, providerName string) (T, error)

DecodeConfig round-trips a provider config (database.JSON) into a typed struct T.

func DecryptStringCredential added in v2.1.0

func DecryptStringCredential(value *string) error

DecryptStringCredential decrypts an encrypted credential in place. A value that fails to decrypt but is not plausibly ciphertext is treated as a legacy raw value.

func Deliver added in v2.3.2

func Deliver(ctx context.Context, provider NotificationProvider, config database.JSON, c Content) (handled bool, err error)

Deliver sends c to a single provider. handled is false for unknown providers.

func EventVars added in v2.7.0

func EventVars(environmentName, environmentID string, event NotificationEventType) map[string]string

EventVars builds the per-event variables exposed to a generic webhook payload template. The names must stay clear of Shoutrrr generic config keys (title, template, contenttype, method, messagekey, titlekey, disabletls) — a colliding param would mutate the per-send service config.

func FormatBytes

func FormatBytes(bytes uint64) string

func IsValidNotificationProvider added in v2.8.1

func IsValidNotificationProvider(provider NotificationProvider) bool

func RenderGenericPayloadTemplate added in v2.7.0

func RenderGenericPayloadTemplate(config GenericConfig, title, message string, vars map[string]string) (string, error)

RenderGenericPayloadTemplate renders the configured payload template with the same variables the Shoutrrr send path exposes. Used by the direct-HTTP path (SuccessBodyContains) and by save-time validation.

func SanitizeForEmail

func SanitizeForEmail(text string) string

SanitizeForEmail sanitizes text for safe use in email subjects

func SendDiscord

func SendDiscord(ctx context.Context, config DiscordConfig, message string) error

SendDiscord sends a message via Shoutrrr Discord using proper service configuration

func SendEmail

func SendEmail(ctx context.Context, config EmailConfig, subject, htmlBody string) error

SendEmail sends pre-rendered HTML via go-mail.

func SendGenericWithTitle

func SendGenericWithTitle(ctx context.Context, config GenericConfig, title, message string, vars map[string]string) error

SendGenericWithTitle sends a message with title via Shoutrrr Generic webhook. When config.SuccessBodyContains is set the response body is also inspected — this is necessary for providers (e.g. PushPlus) that always return HTTP 200 but embed a success/failure indicator inside the JSON body.

func SendGoogleChat added in v2.7.0

func SendGoogleChat(ctx context.Context, config GoogleChatConfig, message string) error

SendGoogleChat sends a message via Shoutrrr's Google Chat service. The service posts plain text only ({"text": ...}) and ignores params, so the title is expected to already be part of the message body.

func SendGotify

func SendGotify(ctx context.Context, config GotifyConfig, message string) error

SendGotify sends a message via Shoutrrr Gotify using proper service configuration

func SendMatrix

func SendMatrix(ctx context.Context, config MatrixConfig, message string) error

SendMatrix sends a message via Shoutrrr Matrix using proper service configuration

func SendNtfy

func SendNtfy(ctx context.Context, config NtfyConfig, message string) error

SendNtfy sends a message via Shoutrrr Ntfy using proper service configuration

func SendPushover

func SendPushover(ctx context.Context, config PushoverConfig, message string) error

SendPushover sends a message via Shoutrrr Pushover using proper service configuration.

func SendSignal

func SendSignal(ctx context.Context, config SignalConfig, message string) error

SendSignal sends a message via Shoutrrr Signal using proper service configuration

func SendSlack

func SendSlack(ctx context.Context, config SlackConfig, message string) error

SendSlack sends a message via Shoutrrr Slack using proper service configuration

func SendTelegram

func SendTelegram(ctx context.Context, config TelegramConfig, message string) error

SendTelegram sends a message via Shoutrrr Telegram using proper service configuration

func TextByFormat added in v2.3.2

func TextByFormat(build func(MessageFormat) string) map[MessageFormat]string

TextByFormat builds the per-format message map for Content.Text from a single messages.go builder closure.

func ValidateGenericPayloadTemplate added in v2.7.0

func ValidateGenericPayloadTemplate(config GenericConfig) error

ValidateGenericPayloadTemplate checks a configured payload template at save time: it must parse, execute against sample variables, and — when the content type is JSON (the default) — render valid JSON. Shoutrrr renders the template internally at send time, so validating here surfaces mistakes against the user's own configuration instead of as an opaque send failure.

Types

type Content added in v2.3.2

type Content struct {
	// Text holds the message body per format, built once per fan-out via the
	// messages.go builders.
	Text map[MessageFormat]string

	// Title is the generic-webhook title.
	Title string

	// DefaultTitle is applied to pushover/gotify when their config has no
	// title; "" means don't default.
	DefaultTitle string

	// RenderEmail lazily renders the email subject and HTML body. Built as a
	// closure by the caller so template resources and app config stay out of
	// this package. Nil means the provider map's email deliverer errors.
	RenderEmail func() (subject, html string, err error)

	// Vars carries per-event variables (environment, environmentId, event,
	// timestamp) for the generic webhook's payload template. They are only
	// injected into the outgoing request when a payload template is configured,
	// so existing template-less generic webhooks keep their exact payload.
	Vars map[string]string

	// RequireNtfyTopic preserves the per-event ntfy topic validation.
	RequireNtfyTopic bool

	// ValidatePushoverUser preserves the per-event pushover token/user validation.
	ValidatePushoverUser bool
}

Content is the provider-independent description of one notification: the message text per format plus the per-event knobs that vary between events.

type DiscordConfig added in v2.8.1

type DiscordConfig struct {
	WebhookID string                         `json:"webhookId"`
	Token     string                         `json:"token"`
	Username  string                         `json:"username,omitempty"`
	AvatarURL string                         `json:"avatarUrl,omitempty"`
	Events    map[NotificationEventType]bool `json:"events,omitempty"`
}

type EmailAuthMode added in v2.8.1

type EmailAuthMode string
const (
	EmailAuthModeNone    EmailAuthMode = "none"
	EmailAuthModeAuto    EmailAuthMode = "auto"
	EmailAuthModePlain   EmailAuthMode = "plain"
	EmailAuthModeLogin   EmailAuthMode = "login"
	EmailAuthModeCRAMMD5 EmailAuthMode = "crammd5"
)

type EmailConfig added in v2.8.1

type EmailConfig struct {
	SMTPHost     string                         `json:"smtpHost"`
	SMTPPort     int                            `json:"smtpPort"`
	SMTPUsername string                         `json:"smtpUsername"`
	SMTPPassword string                         `json:"smtpPassword"`
	FromAddress  string                         `json:"fromAddress"`
	ToAddresses  []string                       `json:"toAddresses"`
	TLSMode      EmailTLSMode                   `json:"tlsMode"`
	AuthMode     EmailAuthMode                  `json:"authMode,omitempty"`
	Events       map[NotificationEventType]bool `json:"events,omitempty"`
}

type EmailTLSMode added in v2.8.1

type EmailTLSMode string
const (
	EmailTLSModeNone     EmailTLSMode = "none"
	EmailTLSModeStartTLS EmailTLSMode = "starttls"
	EmailTLSModeSSL      EmailTLSMode = "ssl"
)

type GenericConfig added in v2.8.1

type GenericConfig struct {
	WebhookURL    string                         `json:"webhookUrl"`
	Method        string                         `json:"method,omitempty"`
	ContentType   string                         `json:"contentType,omitempty"`
	TitleKey      string                         `json:"titleKey,omitempty"`
	MessageKey    string                         `json:"messageKey,omitempty"`
	CustomHeaders map[string]string              `json:"customHeaders,omitempty"`
	DisableTLS    bool                           `json:"disableTls"`
	Events        map[NotificationEventType]bool `json:"events,omitempty"`
	// SuccessBodyContains is an optional substring that must appear in the
	// response body for the send to be considered successful. Useful for
	// providers that always return HTTP 200 but embed a status indicator in
	// the JSON body (e.g. PushPlus returns {"code":200,...} on success and
	// {"code":900,...} on failure). When empty, only the HTTP status code is
	// checked (existing behaviour).
	SuccessBodyContains string `json:"successBodyContains,omitempty"`
	// PayloadTemplate is an optional Go text/template rendered into the request
	// body, letting users target endpoints that require a nested or
	// provider-specific payload shape rather than the flat
	// {"title":...,"message":...} object. The template receives the title and
	// message (under the configured TitleKey/MessageKey) plus event variables
	// (environment, environmentId, event, timestamp), all pre-escaped for JSON
	// string contexts. When empty, the flat JSON payload is used (existing
	// behaviour).
	PayloadTemplate string `json:"payloadTemplate,omitempty"`
}

type GoogleChatConfig added in v2.8.1

type GoogleChatConfig struct {
	// WebhookURL is the full incoming webhook URL copied from Google Chat,
	// e.g. https://chat.googleapis.com/v1/spaces/SPACE/messages?key=KEY&token=TOKEN.
	WebhookURL string                         `json:"webhookUrl"`
	Events     map[NotificationEventType]bool `json:"events,omitempty"`
}

type GotifyConfig added in v2.8.1

type GotifyConfig struct {
	Host               string                         `json:"host"`
	Port               int                            `json:"port,omitempty"`
	Token              string                         `json:"token"`
	Path               string                         `json:"path,omitempty"`
	Priority           int                            `json:"priority,omitempty"`
	Title              string                         `json:"title,omitempty"`
	DisableTLS         bool                           `json:"disableTls"`
	InsecureSkipVerify bool                           `json:"insecureSkipVerify"`
	UseHeader          bool                           `json:"useHeader"`
	Events             map[NotificationEventType]bool `json:"events,omitempty"`
}

func PrepareGotifyConfig added in v2.1.0

func PrepareGotifyConfig(config database.JSON, providerName string) (GotifyConfig, error)

PrepareGotifyConfig decodes and decrypts a Gotify provider config.

type MatrixConfig added in v2.8.1

type MatrixConfig struct {
	Host                   string                         `json:"host"`
	Port                   int                            `json:"port,omitempty"`
	Rooms                  string                         `json:"rooms"`
	Username               string                         `json:"username,omitempty"`
	Password               string                         `json:"password,omitempty"`
	DisableTLSVerification bool                           `json:"disableTlsVerification"`
	Events                 map[NotificationEventType]bool `json:"events,omitempty"`
}

func PrepareMatrixConfig added in v2.1.0

func PrepareMatrixConfig(config database.JSON) (MatrixConfig, error)

PrepareMatrixConfig decodes and decrypts a Matrix provider config.

type MessageFormat

type MessageFormat string
const (
	MessageFormatPlain    MessageFormat = "plain"
	MessageFormatMarkdown MessageFormat = "markdown"
	MessageFormatSlack    MessageFormat = "slack"
	MessageFormatHTML     MessageFormat = "html"
)

type NotificationEventType added in v2.8.1

type NotificationEventType string
const (
	NotificationEventImageUpdate        NotificationEventType = "image_update"
	NotificationEventContainerUpdate    NotificationEventType = "container_update"
	NotificationEventVulnerabilityFound NotificationEventType = "vulnerability_found"
	NotificationEventPruneReport        NotificationEventType = "prune_report"
	NotificationEventAutoHeal           NotificationEventType = "auto_heal"
)

type NotificationProvider added in v2.8.1

type NotificationProvider string
const (
	NotificationProviderDiscord    NotificationProvider = "discord"
	NotificationProviderEmail      NotificationProvider = "email"
	NotificationProviderTelegram   NotificationProvider = "telegram"
	NotificationProviderSignal     NotificationProvider = "signal"
	NotificationProviderSlack      NotificationProvider = "slack"
	NotificationProviderNtfy       NotificationProvider = "ntfy"
	NotificationProviderPushover   NotificationProvider = "pushover"
	NotificationProviderGotify     NotificationProvider = "gotify"
	NotificationProviderMatrix     NotificationProvider = "matrix"
	NotificationProviderGoogleChat NotificationProvider = "googlechat"
	NotificationProviderGeneric    NotificationProvider = "generic"
)

type NtfyConfig added in v2.8.1

type NtfyConfig struct {
	Host                   string                         `json:"host"`
	Port                   int                            `json:"port"`
	Topic                  string                         `json:"topic"`
	Username               string                         `json:"username,omitempty"`
	Password               string                         `json:"password,omitempty"`
	Title                  string                         `json:"title,omitempty"`
	Priority               string                         `json:"priority,omitempty"`
	Tags                   []string                       `json:"tags,omitempty"`
	Icon                   string                         `json:"icon,omitempty"`
	Cache                  bool                           `json:"cache"`
	Firebase               bool                           `json:"firebase"`
	DisableTLS             bool                           `json:"disableTls"`
	DisableTLSVerification bool                           `json:"disableTlsVerification"`
	Events                 map[NotificationEventType]bool `json:"events,omitempty"`
}

func PrepareNtfyConfig added in v2.1.0

func PrepareNtfyConfig(config database.JSON, providerName string, requireTopic bool) (NtfyConfig, error)

PrepareNtfyConfig decodes and decrypts an ntfy provider config.

type PushoverConfig added in v2.8.1

type PushoverConfig struct {
	Token    string                         `json:"token"`
	User     string                         `json:"user"`
	Devices  []string                       `json:"devices,omitempty"`
	Priority int8                           `json:"priority"`
	Title    string                         `json:"title,omitempty"`
	Events   map[NotificationEventType]bool `json:"events,omitempty"`
}

func PreparePushoverConfig added in v2.1.0

func PreparePushoverConfig(config database.JSON, providerName string) (PushoverConfig, error)

PreparePushoverConfig decodes and decrypts a Pushover provider config.

type SignalConfig added in v2.8.1

type SignalConfig struct {
	Host       string                         `json:"host"`
	Port       int                            `json:"port"`
	User       string                         `json:"user,omitempty"`
	Password   string                         `json:"password,omitempty"`
	Token      string                         `json:"token,omitempty"`
	Source     string                         `json:"source"`
	Recipients []string                       `json:"recipients"`
	DisableTLS bool                           `json:"disableTls"`
	Events     map[NotificationEventType]bool `json:"events,omitempty"`
}

type SlackConfig added in v2.8.1

type SlackConfig struct {
	Token    string                         `json:"token"`
	BotName  string                         `json:"botName,omitempty"`
	Icon     string                         `json:"icon,omitempty"`
	Color    string                         `json:"color,omitempty"`
	Title    string                         `json:"title,omitempty"`
	Channel  string                         `json:"channel,omitempty"`
	ThreadTS string                         `json:"threadTs,omitempty"`
	Events   map[NotificationEventType]bool `json:"events,omitempty"`
}

func PrepareSlackConfig added in v2.1.0

func PrepareSlackConfig(config database.JSON, providerName string, requireToken bool) (SlackConfig, error)

PrepareSlackConfig decodes and decrypts a Slack provider config.

type TelegramConfig added in v2.8.1

type TelegramConfig struct {
	BotToken     string                         `json:"botToken"`
	ChatIDs      []string                       `json:"chatIds"`
	Preview      bool                           `json:"preview"`
	Notification bool                           `json:"notification"`
	ParseMode    string                         `json:"parseMode,omitempty"`
	Title        string                         `json:"title,omitempty"`
	Events       map[NotificationEventType]bool `json:"events,omitempty"`
}

Jump to

Keyboard shortcuts

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