notification

package
v0.2.6-rc Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

pkg/notification

The notification package dispatches alerts when a Katalog condition evaluates to true. It supports email (SMTP) and Slack channels, with per-team interval enforcement to prevent alert floods.

Notifications are condition-driven: a condition that is true triggers its notify: block. Each team listed in the block receives a message through every channel configured for that team. A per-condition, per-team timestamp gate suppresses re-delivery until the declared interval has elapsed.

What lives here

File Role
notification.go NotificationState — per-team timestamp tracking; ProcessConditionNotifications entry point; dispatchTeamNotifications fan-out
email.go sendEmailNotification — SMTP dispatch; SMTPConfig; STARTTLS upgrade
slack.go sendSlackNotification — Incoming Webhook POST; SlackPayload JSON builder

Developer documentation

Full step-by-step documentation is in docs/.

I want to… Go to
Understand the notification flow from condition to delivery 01 — Overview
Configure notify: on a condition 02 — NotifyBlock
Add a new channel or understand email / Slack dispatch 03 — Channels

Documentation

Overview

pkg/notification/email.go

Email notification dispatch via SMTP. SMTP credentials are read from pkg/konfig env vars:

SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS, SMTP_FROM

Recipients are declared per team in the Katalog notification config. Multiple recipients receive one email each (BCC is not used — per-recipient tracking allows future per-recipient suppression).

pkg/notification/slack.go

Slack notification dispatch via incoming webhooks. One HTTP POST per channel per send. Channels are notified in parallel.

Message format: plain text with Markdown-like formatting that Slack renders. The message template is evaluated against the full resolver data map before dispatch so it can reference .spec.*, .metadata.*, .status.*, metrics.*, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NotificationStack

type NotificationStack struct {
	Katalog      *katalog.Katalog
	State        *NotificationState
	ResolverData map[string]interface{}
}

type NotificationState

type NotificationState struct {
	// key: operatorName + "|" + conditionKey + "|" + teamName
	LastSent map[string]time.Time
}

NotificationState tracks last-send timestamps per condition+team.

func NewNotificationState

func NewNotificationState() *NotificationState

func (*NotificationState) ProcessConditionNotifications

func (s *NotificationState) ProcessConditionNotifications(
	ctx context.Context,
	k *katalog.Katalog,
	data map[string]interface{},
	cond orktypes.Condition,
	now time.Time,
)

ProcessConditionNotifications evaluates notify: for a single condition, tracking transitions and enforcing per-team intervals.

Called after we've already decided the condition is "passed" (true).

type SMTPConfig added in v0.1.9

type SMTPConfig struct {
	Host string
	Port string // default "587"
	User string
	Pass string
	From string
}

SMTPConfig holds the SMTP connection parameters read from pkg/konfig. Constructed by the caller (notification.Notifier) from konfig at startup.

func (SMTPConfig) EffectivePort added in v0.1.9

func (c SMTPConfig) EffectivePort() string

EffectivePort returns the port, defaulting to 587 (STARTTLS submission).

func (SMTPConfig) IsConfigured added in v0.1.9

func (c SMTPConfig) IsConfigured() bool

IsConfigured returns true when the minimum required SMTP fields are present.

Jump to

Keyboard shortcuts

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