Documentation ¶
Index ¶
- type CompilationError
- type CostError
- type Errors
- func (l *Errors) AddCompilationErrors(compileErrors []*CompilationError)
- func (l *Errors) AddCostErrors(costErrors []*CostError)
- func (l *Errors) AddInternalErrors(internalErrors []error)
- func (l *Errors) AddLimitErrors(limitErrors []*LimitError)
- func (l *Errors) AddLinterErrors(otherLinterErrors *Errors)
- func (l *Errors) HasErrors() bool
- func (l *Errors) MarshalJSON() ([]byte, error)
- type LimitError
- type SchemaType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompilationError ¶
type CompilationError struct { // Path represents the path to the schema node containing the expression. Path *field.Path // Message represents the error message generated by CEL.. Message string }
CompilationError represents an expression that contained a compile-time error.
func (*CompilationError) Error ¶
func (c *CompilationError) Error() string
func (*CompilationError) MarshalJSON ¶
func (c *CompilationError) MarshalJSON() ([]byte, error)
MarshalJSON returns the CompilationError in JSON format.
type CostError ¶
type CostError struct { // Path represents the path to the schema node containing the expression. Path *field.Path // Cost represents the cost of the expression. This is a unitless value. Cost uint64 // Limit represents the cost limit that was exceeded. This is a unitless value. Limit uint64 }
CostError represents an expression whose cost is beyond the per-expression limit.
func (*CostError) HumanReadableError ¶
HumanReadableError returns an error message containing the amount by which the expression exceeded the cost limit as a ratio.
func (*CostError) MarshalJSON ¶
MarshalJSON returns the CostError in JSON format.
type Errors ¶
type Errors struct { LimitErrors []*LimitError CostErrors []*CostError CompileErrors []*CompilationError InternalErrors []error // contains filtered or unexported fields }
Errors is meant to track the errors found during a linting pass.
func CheckExprCost ¶
func CheckExprCost(schema *structuralschema.Structural, version *int) *Errors
CheckExprCost checks the given schema for expressions whose estimated cost is greater than the per-expression cost limit. If any compilation errors are encountered during this process, then those are returned as well. The last set of errors returned is for internal errors returned by cel.Compile.
func CheckMaxLimits ¶
func CheckMaxLimits(schema *structuralschema.Structural, version *int) *Errors
CheckMaxLimits takes a schema and returns a list of linter errors for every missing limit that could be set on a list/map/string belonging to that schema or any level beneath it.
func NewLinterErrors ¶
func NewLinterErrors() *Errors
NewLinterErrors returns a new initialized LinterErrors struct.
func (*Errors) AddCompilationErrors ¶
func (l *Errors) AddCompilationErrors(compileErrors []*CompilationError)
AddCompilationErrors adds a list of compilation linter errors.
func (*Errors) AddCostErrors ¶
AddCostErrors adds a list of cost linter errors.
func (*Errors) AddInternalErrors ¶
AddInternalErrors adds a list of internal errors.
func (*Errors) AddLimitErrors ¶
func (l *Errors) AddLimitErrors(limitErrors []*LimitError)
AddLimitErrors adds a list of limit linter errors.
func (*Errors) AddLinterErrors ¶
AddLinterErrors adds all errors from another LinterErrors struct.
func (*Errors) HasErrors ¶
HasErrors returns true if a non-zero amount of errors has been added, false otherwise.
func (*Errors) MarshalJSON ¶
MarshalJSON returns the LinterErrors in JSON format.
type LimitError ¶
type LimitError struct { // Path represents the path to the list, map or string without the limit. Path *field.Path // Type indicates the type of the schema node that caused the error. Type SchemaType }
LimitError represents a list, map, or string that lacks a user-set limit. For lists, this means maxItems has not been set. For maps, this means maxProperties has not been set. And for strings this means maxLength has not been set.
func (*LimitError) Error ¶
func (l *LimitError) Error() string
func (*LimitError) MarshalJSON ¶
func (l *LimitError) MarshalJSON() ([]byte, error)
MarshalJSON returns the LimitError in JSON format.
type SchemaType ¶
type SchemaType int
SchemaType represents an array, map or string as used by LimitError.
const ( // SchemaTypeArray represents an array as used by LimitError. SchemaTypeArray SchemaType = iota // SchemaTypeObject represents an object with additionalProperties // as used by LimitError. SchemaTypeObject // SchemaTypeString represents a string as used by LimitError. SchemaTypeString )