Documentation
¶
Index ¶
Constants ¶
const ( KindAlert = "alert" KindVariable = "variable" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertCtx ¶
AlertCtx represents contextual information for alert-related events. It's used in matching rules.'
type AlertTrigger ¶
type AlertTrigger struct {
// Name is required by Match; empty names do not match.
Name string `json:"name,omitempty"`
// Status is optional; when empty, status is ignored.
Status string `json:"status,omitempty"`
}
AlertTrigger matches events based on alert name and status.
func (*AlertTrigger) MarshalLogObject ¶
func (t *AlertTrigger) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject encodes the trigger as a log object.
func (*AlertTrigger) Match ¶
func (t *AlertTrigger) Match(ctx Context) bool
Match checks if the trigger matches the given context.
type Context ¶
type Context struct {
Alert *AlertCtx // nil unless this was an alert
Variable *VariableCtx // nil unless this was a variable
Now time.Time
}
Context for event matching AlertCtx and VariableCtx represent different types of context for different trigger types
type Trigger ¶
type Trigger interface {
// Match event with trigger
Match(ctx Context) bool
// Kind of the trigger
Kind() string
}
Trigger interface for various event triggers
func BuildTrigger ¶
func BuildTrigger(raw json.RawMessage) (Trigger, error)
BuildTrigger parses raw JSON into a Trigger Returns an error if the raw JSON is invalid or the trigger kind is unknown.
type VariableCtx ¶
type VariableCtx struct {
Name string `json:"name"` // variable key
UpdateType string `json:"update_type"` // "added" | "removed" | "changed"
Value string `json:"value,omitempty"` // current value if applicable
}
VariableCtx represents contextual information for variable-related events. It's used in matching rules.
type VariableTrigger ¶
type VariableTrigger struct {
Name string `json:"name,omitempty"` // exact; "" = any
// TODO add UpdateType to CRD
UpdateType string `json:"update_type,omitempty"` // "added", "removed", "changed"
}
VariableTrigger matches events based on variable name and update type.
func (*VariableTrigger) Kind ¶
func (t *VariableTrigger) Kind() string
Kind returns the kind of trigger.
func (*VariableTrigger) MarshalLogObject ¶
func (t *VariableTrigger) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject encodes the trigger as a log object.
func (*VariableTrigger) Match ¶
func (t *VariableTrigger) Match(ctx Context) bool
Match checks if the trigger matches the given context.