notifications

package
v1.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderJSONTemplate added in v0.13.0

func RenderJSONTemplate(templateData map[string]interface{}, celInputs map[string]interface{}, logger *slog.Logger) (map[string]interface{}, error)

RenderJSONTemplate renders a JSON template with CEL expressions for webhook payloads. It expects the template to be a parsed JSON map and returns the rendered map. If rendering fails, an error is returned. celInputs should be the precomputed map from AlertDetails.ToMap() for better performance.

func RenderPlaintextTemplate added in v0.13.0

func RenderPlaintextTemplate(templateStr string, celInputs map[string]interface{}, logger *slog.Logger) string

RenderPlaintextTemplate renders a plaintext template with CEL expressions for email subjects and bodies. It treats the template as a plain string and evaluates CEL expressions within it. If any CEL expression fails to resolve, a warning is logged and the original expression is preserved in the output. celInputs should be the precomputed map from AlertDetails.ToMap() for better performance.

func SendAlertNotification added in v0.13.0

func SendAlertNotification(ctx context.Context, config *NotificationChannelConfig, alertDetails *types.AlertDetails, logger *slog.Logger) error

SendAlertNotification sends an alert notification via the configured notification channel. It handles template rendering for payloads internally.

func SendEmailWithConfig

func SendEmailWithConfig(_ context.Context, config *NotificationChannelConfig, subject, body string) error

SendEmailWithConfig sends an alert email using the provided configuration.

func SendWebhookWithConfig added in v0.12.0

func SendWebhookWithConfig(ctx context.Context, config *WebhookConfig, alertDetails map[string]interface{}) error

SendWebhookWithConfig sends an alert webhook using the provided configuration. It sends the alertDetails JSON object as the request body.

Types

type EmailConfig

type EmailConfig struct {
	SMTP            SMTPConfig
	To              []string
	SubjectTemplate string
	BodyTemplate    string
}

EmailConfig holds email-specific configuration

func PrepareEmailNotificationConfig added in v0.13.0

func PrepareEmailNotificationConfig(configMap *corev1.ConfigMap, secret *corev1.Secret, logger *slog.Logger) (EmailConfig, error)

PrepareEmailNotificationConfig prepares email notification configuration from ConfigMap and Secret

type NotificationChannelConfig

type NotificationChannelConfig struct {
	Type    string // "email" or "webhook"
	Email   EmailConfig
	Webhook WebhookConfig
}

NotificationChannelConfig combines email and webhook configuration

type SMTPConfig

type SMTPConfig struct {
	Host     string
	Port     int
	Username string
	Password string
	From     string
}

SMTPConfig holds SMTP configuration for sending emails

type WebhookConfig added in v0.12.0

type WebhookConfig struct {
	URL             string
	Headers         map[string]string
	PayloadTemplate string // Optional JSON template with CEL expressions
}

WebhookConfig holds webhook configuration for sending alerts

func PrepareWebhookNotificationConfig added in v0.13.0

func PrepareWebhookNotificationConfig(configMap *corev1.ConfigMap, secret *corev1.Secret, logger *slog.Logger) (WebhookConfig, error)

PrepareWebhookNotificationConfig prepares webhook notification configuration from ConfigMap and Secret

Jump to

Keyboard shortcuts

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