notify

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package notify delivers expiry, renewal and revocation events to webhooks, SMTP, Slack and Telegram. Delivery is best-effort: a channel that is down must never block or fail the PKI operation that triggered it.

Index

Constants

View Source
const (
	EventCertificateExpiring = "certificate.expiring"
	EventCertificateExpired  = "certificate.expired"
	EventCertificateRenewed  = "certificate.renewed"
	EventCertificateRevoked  = "certificate.revoked"
	EventCertificateIssued   = "certificate.issued"
	EventAuthorityExpiring   = "authority.expiring"
	EventRenewalFailed       = "renewal.failed"
	EventTest                = "test"
)

Event names channels can subscribe to. "*" matches every event.

Variables

This section is empty.

Functions

func EventNames

func EventNames() []string

EventNames lists every event, for the settings UI.

Types

type Event

type Event struct {
	Type      string         `json:"event"`
	Title     string         `json:"title"`
	Message   string         `json:"message"`
	Severity  string         `json:"severity"`
	Timestamp time.Time      `json:"timestamp"`
	Data      map[string]any `json:"data,omitempty"`
}

Event is one notification payload.

type Notifier

type Notifier interface {
	Send(ctx context.Context, event Event) error
	Channel() string
}

Notifier sends an event through one configured channel.

func Build

func Build(channel string, config map[string]string) (Notifier, error)

Build constructs a Notifier from a channel name and its decrypted settings.

type SMTP

type SMTP struct {
	Host     string
	Port     int
	Username string
	Password string
	From     string
	To       []string
	// TLS selects the transport: "starttls" (default), "tls" for implicit TLS,
	// or "none" for a plaintext relay on a trusted network.
	TLS string
	// InsecureSkipVerify disables certificate verification. It exists because
	// a private PKI is often bootstrapped against a mail server whose
	// certificate this very instance has not yet issued.
	InsecureSkipVerify bool
}

SMTP sends the event as an email.

func (*SMTP) Channel

func (s *SMTP) Channel() string

Channel identifies the transport.

func (*SMTP) Send

func (s *SMTP) Send(ctx context.Context, event Event) error

Send delivers the event by email.

type Slack

type Slack struct {
	WebhookURL string
	Channel_   string
	Username   string
}

Slack posts to an incoming-webhook URL.

func (*Slack) Channel

func (s *Slack) Channel() string

Channel identifies the transport.

func (*Slack) Send

func (s *Slack) Send(ctx context.Context, event Event) error

Send posts a Block Kit message.

type Telegram

type Telegram struct {
	BotToken string
	ChatID   string
	// ThreadID targets one topic inside a forum-style supergroup. Empty sends
	// to the general thread.
	ThreadID string
	// Silent delivers without a notification sound.
	Silent bool
	// APIBaseURL overrides the public Bot API root, for a self-hosted server.
	APIBaseURL string
}

Telegram sends the event to a chat through a bot.

func (*Telegram) Channel

func (t *Telegram) Channel() string

Channel identifies the transport.

func (*Telegram) Send

func (t *Telegram) Send(ctx context.Context, event Event) error

Send posts the event as an HTML-formatted message.

type Webhook

type Webhook struct {
	URL     string
	Secret  string
	Headers map[string]string
}

Webhook posts the event as JSON.

func (*Webhook) Channel

func (w *Webhook) Channel() string

Channel identifies the transport.

func (*Webhook) Send

func (w *Webhook) Send(ctx context.Context, event Event) error

Send posts the event to the configured URL.

Jump to

Keyboard shortcuts

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