notify

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHTTPTimeout = 10 * time.Second

DefaultHTTPTimeout is the timeout for webhook and Slack HTTP requests.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleNotifier

type ConsoleNotifier struct {
	Filter string
}

ConsoleNotifier prints events to stdout.

func (*ConsoleNotifier) Notify

func (c *ConsoleNotifier) Notify(event Event) error

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher fans out events to multiple notifiers.

func NewDispatcher

func NewDispatcher(cfg policy.NotificationCfg) *Dispatcher

NewDispatcher builds a dispatcher from the policy notification config.

func (*Dispatcher) Send

func (d *Dispatcher) Send(event Event)

Send dispatches an event to all matching notifiers. Errors are logged but do not stop delivery to other notifiers.

type Event

type Event struct {
	Type      string               `json:"type"` // "approval_required", "denied", "allowed"
	Timestamp time.Time            `json:"timestamp"`
	Request   policy.ActionRequest `json:"request"`
	Result    policy.CheckResult   `json:"result"`
	// ApprovalURL is set when Type == "approval_required".
	ApprovalURL string `json:"approval_url,omitempty"`
}

Event describes something that happened in the system.

type LogNotifier

type LogNotifier struct {
	Level  string
	Filter string
}

LogNotifier logs events via the standard logger.

func (*LogNotifier) Notify

func (l *LogNotifier) Notify(event Event) error

type Notifier

type Notifier interface {
	Notify(event Event) error
}

Notifier delivers events to external systems.

type SlackNotifier

type SlackNotifier struct {
	WebhookURL string
	Filter     string
	// contains filtered or unexported fields
}

SlackNotifier posts a formatted message to a Slack incoming webhook.

func (*SlackNotifier) Notify

func (s *SlackNotifier) Notify(event Event) error

type WebhookNotifier

type WebhookNotifier struct {
	URL    string
	Filter string // only fire for this event type ("" = all)
	// contains filtered or unexported fields
}

WebhookNotifier posts JSON to an arbitrary URL.

func (*WebhookNotifier) Notify

func (w *WebhookNotifier) Notify(event Event) error

Jump to

Keyboard shortcuts

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