Documentation ¶
Index ¶
Constants ¶
View Source
const (
JSONPathPrefix string = "jsonpath::"
)
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 (
ErrInvalidJSONPath = fmt.Errorf("invalid JSONPath")
)
View Source
var ErrNoValuesFound = errors.New("no values were found")
Functions ¶
func NewJSONPathFromString ¶
func TrimJSONPath ¶
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 Range ¶
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 string `json:"rule"` Name string `json:"name"` Path string `json:"path"` Message string `json:"message"` // optional keys Valid string `json:"valid,omitempty"` JustWarning bool `json:"justWarning,omitempty"` // arguments (optional keys) Values []string `json:"values,omitempty"` Min interface{} `json:"min,omitempty"` Max interface{} `json:"max,omitempty"` MinLength interface{} `json:"minLength,omitempty"` MaxLength interface{} `json:"maxLength,omitempty"` Regex string `json:"regex,omitempty"` }
func ParseRules ¶
func (*Rule) IsAppliableOn ¶
func (r *Rule) IsAppliableOn(vm *k6tv1.VirtualMachine) (bool, error)
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.