Versions in this module Expand all Collapse all v0 v0.9.0 Oct 20, 2021retracted Changes in this version + var ErrDefinitionIDConflict = errors.New("multiple definition with the same ID") + var ErrEventTypeNotEnabled = errors.New("event type not enabled") + var ErrInternalIDConflict = errors.New("internal rule ID conflict") + var ErrRuleWithMultipleEvents = errors.New("rule with multiple events is not supported") + var ErrRuleWithoutEvent = errors.New("no event in the rule definition") + func LoadPolicies(policiesDir string, ruleSet *RuleSet) *multierror.Error + type Approvers map[eval.Field]FilterValues + type ErrFieldTypeUnknown struct + Field string + func (e *ErrFieldTypeUnknown) Error() string + type ErrMacroLoad struct + Definition *MacroDefinition + Err error + func (e ErrMacroLoad) Error() string + type ErrNoApprover struct + Fields []string + func (e ErrNoApprover) Error() string + type ErrNoEventTypeBucket struct + EventType string + func (e ErrNoEventTypeBucket) Error() string + type ErrPoliciesLoad struct + Err error + Name string + func (e ErrPoliciesLoad) Error() string + type ErrPolicyLoad struct + Err error + Name string + func (e ErrPolicyLoad) Error() string + type ErrRuleLoad struct + Definition *RuleDefinition + Err error + func (e ErrRuleLoad) Error() string + type ErrValueTypeUnknown struct + Field string + func (e *ErrValueTypeUnknown) Error() string + type FieldCapabilities []FieldCapability + func (fcs FieldCapabilities) GetFields() []eval.Field + func (fcs FieldCapabilities) Validate(approvers map[eval.Field]FilterValues) bool + type FieldCapability struct + Field eval.Field + Types eval.FieldValueType + ValidateFnc func(FilterValue) bool + type FieldCombinations [][]eval.Field + func (a FieldCombinations) Len() int + func (a FieldCombinations) Less(i, j int) bool + func (a FieldCombinations) Swap(i, j int) + type FilterValue struct + Field eval.Field + Not bool + Type eval.FieldValueType + Value interface{} + type FilterValues []FilterValue + func (fv FilterValues) Merge(n FilterValues) FilterValues + type Logger interface + Debugf func(format string, params ...interface{}) + Errorf func(format string, params ...interface{}) + Infof func(format string, params ...interface{}) + Tracef func(format string, params ...interface{}) + type Macro struct + Definition *MacroDefinition + type MacroDefinition struct + Expression string + ID MacroID + type MacroID = string + type NullLogger struct + func (l NullLogger) Debugf(format string, params ...interface{}) + func (l NullLogger) Errorf(format string, params ...interface{}) + func (l NullLogger) Infof(format string, params ...interface{}) + func (l NullLogger) Tracef(format string, params ...interface{}) + type Opts struct + EventTypeEnabled map[eval.EventType]bool + Logger Logger + ReservedRuleIDs []RuleID + SupportedDiscarders map[eval.Field]bool + func NewOptsWithParams(constants map[string]interface{}, supportedDiscarders map[eval.Field]bool, ...) *Opts + type Policy struct + Macros []*MacroDefinition + Name string + Rules []*RuleDefinition + Version string + func LoadPolicy(r io.Reader, name string) (*Policy, error) + func (p *Policy) GetValidMacroAndRules() ([]*MacroDefinition, []*RuleDefinition, *multierror.Error) + type Rule struct + Definition *RuleDefinition + type RuleBucket struct + func (rb *RuleBucket) AddRule(rule *Rule) error + func (rb *RuleBucket) GetApprovers(event eval.Event, fieldCaps FieldCapabilities) (Approvers, error) + func (rb *RuleBucket) GetRules() []*Rule + type RuleDefinition struct + Description string + Expression string + ID RuleID + Policy *Policy + Tags map[string]string + Version string + func (rd *RuleDefinition) GetTags() []string + type RuleID = string + type RuleSet struct + func NewRuleSet(model eval.Model, eventCtor func() eval.Event, opts *Opts) *RuleSet + func (rs *RuleSet) AddFields(fields []eval.EventType) + func (rs *RuleSet) AddListener(listener RuleSetListener) + func (rs *RuleSet) AddMacro(macroDef *MacroDefinition) (*eval.Macro, error) + func (rs *RuleSet) AddMacros(macros []*MacroDefinition) *multierror.Error + func (rs *RuleSet) AddPolicyVersion(filename string, version string) + func (rs *RuleSet) AddRule(ruleDef *RuleDefinition) (*eval.Rule, error) + func (rs *RuleSet) AddRules(rules []*RuleDefinition) *multierror.Error + func (rs *RuleSet) Evaluate(event eval.Event) bool + func (rs *RuleSet) GetApprovers(fieldCaps map[eval.EventType]FieldCapabilities) (map[eval.EventType]Approvers, error) + func (rs *RuleSet) GetBucket(eventType eval.EventType) *RuleBucket + func (rs *RuleSet) GetEventApprovers(eventType eval.EventType, fieldCaps FieldCapabilities) (Approvers, error) + func (rs *RuleSet) GetEventTypes() []eval.EventType + func (rs *RuleSet) GetFieldValues(field eval.Field) []eval.FieldValue + func (rs *RuleSet) GetRules() map[eval.RuleID]*Rule + func (rs *RuleSet) HasRulesForEventType(eventType eval.EventType) bool + func (rs *RuleSet) IsDiscarder(event eval.Event, field eval.Field) (bool, error) + func (rs *RuleSet) ListMacroIDs() []MacroID + func (rs *RuleSet) ListRuleIDs() []RuleID + func (rs *RuleSet) NotifyDiscarderFound(event eval.Event, field eval.Field, eventType eval.EventType) + func (rs *RuleSet) NotifyRuleMatch(rule *Rule, event eval.Event) + type RuleSetListener interface + EventDiscarderFound func(rs *RuleSet, event eval.Event, field eval.Field, eventType eval.EventType) + RuleMatch func(rule *Rule, event eval.Event)