Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnrecognizedRuleType = errors.New("unrecognized Rule type") ErrDuplicateRuleName = errors.New("duplicate Rule Name") ErrMissingRequiredKey = errors.New("missing required key") ErrUnsatisfiedRule = errors.New("rule is not satisfied") )
View Source
var ErrNoValuesFound = errors.New("no values were found")
Functions ¶
This section is empty.
Types ¶
type Evaluator ¶
func NewEvaluator ¶
func NewEvaluator() *Evaluator
func (*Evaluator) Evaluate ¶
func (ev *Evaluator) Evaluate(rules []Rule, vm *k6tv1.VirtualMachine) *Result
Evaluate applies *all* the rules (greedy evaluation) to the given VM. Returns a Report for each applied Rule, but ordering isn't guaranteed. Use Report.Ref to crosslink Reports with Rules. The 'bool' return value is a syntetic result, it is true if Evaluation succeeded. The 'error' return value signals *internal* evaluation error. IOW 'false' evaluation *DOES NOT* imply error != nil
type Result ¶
type Result struct { Status []Report // contains filtered or unexported fields }
func (*Result) ToStatusCauses ¶
func (r *Result) ToStatusCauses() []metav1.StatusCause
type Rule ¶
type Rule struct { // mandatory keys Rule RuleType `json:"rule"` Name string `json:"name"` Path path.Path `json:"path"` Message string `json:"message"` // optional keys Valid *path.Path `json:"valid,omitempty"` JustWarning bool `json:"justWarning,omitempty"` // arguments (optional keys) Values []path.StringOrPath `json:"values,omitempty"` Min *path.IntOrPath `json:"min,omitempty"` Max *path.IntOrPath `json:"max,omitempty"` MinLength *path.IntOrPath `json:"minLength,omitempty"` MaxLength *path.IntOrPath `json:"maxLength,omitempty"` Regex string `json:"regex,omitempty"` }
func ParseRules ¶
func (*Rule) IsAppliableOn ¶
func (r *Rule) IsAppliableOn(vm *k6tv1.VirtualMachine) bool
func (*Rule) Specialize ¶
func (r *Rule) Specialize(vm, ref *k6tv1.VirtualMachine) (RuleApplier, error)
we need a vm reference to specialize a rule because few key fields may be JSONPath, and we need to walk them to get e.g. the value to check, or the limits to enforce.
type RuleApplier ¶
type RuleApplier interface { Apply(vm, ref *k6tv1.VirtualMachine) (bool, error) String() string }
func NewEnumRule ¶
func NewEnumRule(r *Rule, vm, ref *k6tv1.VirtualMachine) (RuleApplier, error)
func NewIntRule ¶
func NewIntRule(r *Rule, vm, ref *k6tv1.VirtualMachine) (RuleApplier, error)
func NewRegexRule ¶
func NewRegexRule(r *Rule) (RuleApplier, error)
func NewStringRule ¶
func NewStringRule(r *Rule, vm, ref *k6tv1.VirtualMachine) (RuleApplier, error)
Click to show internal directories.
Click to hide internal directories.