Documentation
¶
Index ¶
Constants ¶
const DefaultFailureRepeatInterval = time.Hour
DefaultFailureRepeatInterval is how long an unchanged failure stays quiet before it is sent again as a reminder.
Variables ¶
var ErrInvalidTemplate = errors.New("invalid notification template")
ErrInvalidTemplate is returned when the configured notification body template fails to parse or execute.
var ErrNotifyFailed = errors.New("request to apprise failed")
ErrNotifyFailed is returned when the Apprise request fails due to invalid notify URLs or unreachable service.
var ErrNotifyPartial = fmt.Errorf("%w: partial delivery", ErrNotifyFailed)
ErrNotifyPartial is returned when Apprise delivered to at least one configured destination but another destination failed.
Functions ¶
func GetRevision ¶ added in v0.32.1
func MarkNotified ¶ added in v0.110.0
MarkNotified marks err as already reported. A nil error stays nil.
func WasNotified ¶ added in v0.110.0
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 Config ¶ added in v0.115.0
type Config struct {
APIURL string
NotifyURLs string
NotifyLevel string
BodyTemplate string
FailureRepeatInterval time.Duration
}
Config defines the immutable Apprise settings and failure-repeat behavior of a Notifier.
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 whose image moved; empty on the first deployment of a stack
DeploymentTargetObserver func(stack, context string)
}
type Notifier ¶ added in v0.115.0
type Notifier struct {
// contains filtered or unexported fields
}
Notifier owns notification configuration and repeat-failure state.
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 Sender ¶ added in v0.115.0
type Sender interface {
Send(level Level, title, message string, metadata Metadata, opts ...SendOption) error
}
Sender is the notification capability consumed by application services.
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 }}.