notification

package
v0.111.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Info    level = iota // Informational messages
	Success              // Successful operations
	Warning              // Warning messages indicating potential issues
	Failure              // Error messages indicating failure of operations
)
View Source
const DefaultFailureRepeatInterval = time.Hour

DefaultFailureRepeatInterval is how long an unchanged failure stays quiet before it is sent again as a reminder.

Variables

View Source
var ErrInvalidTemplate = errors.New("invalid notification template")

ErrInvalidTemplate is returned when the configured notification body template fails to parse or execute.

View Source
var ErrNotifyFailed = errors.New("request to apprise failed")

ErrNotifyFailed is returned when the Apprise request fails due to invalid notify URLs or unreachable service.

Functions

func GetRevision added in v0.32.1

func GetRevision(reference, commitSHA string) string

func MarkNotified added in v0.110.0

func MarkNotified(err error) error

MarkNotified marks err as already reported. A nil error stays nil.

func Send

func Send(level level, title, message string, metadata Metadata, opts ...SendOption) error

Send sends a notification using the Apprise service based on the provided configuration and parameters.

func SetAppriseConfig

func SetAppriseConfig(apiURL, notifyUrls, notifyLevel, bodyTemplate string) error

SetAppriseConfig sets the configuration for the Apprise notification service. bodyTemplate is an optional Go text/template rendering the notification body; an empty string keeps the built-in format (defaultTemplate). An invalid template is rejected.

func SetFailureRepeatInterval added in v0.110.0

func SetFailureRepeatInterval(interval time.Duration)

SetFailureRepeatInterval sets how long an unchanged failure is suppressed. Zero or less turns suppression off entirely: every failure is sent, as it was before this existed.

func WasNotified added in v0.110.0

func WasNotified(err error) bool

WasNotified reports whether a failure notification was already sent for err. It walks the unwrap chain, so every layer above MarkNotified must wrap with %w. An error rebuilt on the way up - fmt.Errorf("...: %v", err), errors.New(err.Error()), a fresh sentinel - drops the mark and gets notified a second time.

Types

type Metadata added in v0.32.1

type Metadata struct {
	Repository          string
	Stack               string
	Context             string // Docker context the stack is deployed to (empty = default context)
	Target              string // Custom webhook/poll target suffix (e.g., "prod-vm" for .doco-cd.prod-vm.yml)
	Revision            string
	JobID               string
	TraceID             string
	ReconciliationEvent string
	AffectedActorKind   string
	AffectedActorID     string
	AffectedActorName   string
	Commits             []git.CommitInfo // commits deployed since the last deploy; empty on first deploy/failure/OCI
	Duration            time.Duration    // time from job start to the notification; zero when no deploy/destroy ran
	ChangedServices     []string         // services force-recreated by this deploy or with image digest drift; empty when the whole stack is (re)deployed
}

type SendOption added in v0.103.0

type SendOption func(*sendOptions)

SendOption customizes how a notification is rendered/sent.

func WithoutBodyTemplate added in v0.103.0

func WithoutBodyTemplate() SendOption

WithoutBodyTemplate renders the notification with the built-in body format, ignoring any configured APPRISE_NOTIFY_BODY_TEMPLATE. Use it for app-level notifications (e.g. the "new version available" ping) that are not tied to a deployment and therefore carry no stack/context/revision the template expects.

type TemplateData added in v0.103.0

type TemplateData struct {
	Level            string // notification level: info, success, warning or failure
	Emoji            string // level emoji (ℹ️/✅/⚠️/❌)
	Title            string // notification title, e.g. "Deployment completed"
	Message          string // core notification message
	IsReconciliation bool   // true when triggered by a reconciliation event
	Metadata                // embedded metadata fields
}

TemplateData is the data exposed to a user-configured notification body template. Metadata is embedded, so its fields (Repository, Stack, Revision, JobID, ...) are referenced directly, e.g. {{.Stack}} or {{.Repository}}.

func (TemplateData) DefaultBody added in v0.103.0

func (d TemplateData) DefaultBody() string

DefaultBody renders the built-in notification body: the message text followed by structured metadata. It backs defaultTemplate and is exposed to user templates as {{ .DefaultBody }}.

Jump to

Keyboard shortcuts

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