diff --git a/cel/options.go b/cel/options.go index f36188921..0287da9e8 100644 --- a/cel/options.go +++ b/cel/options.go @@ -903,8 +903,8 @@ func ParserRecursionLimit(limit int) EnvOption { return setLimit(limitParseRecursionDepth, limit) } -// ParserRecursionLimit adjusts the AST depth the parser will tolerate. -// Defaults defined in the parser package. +// ParserErrorRecoveryLimit sets the number of attemtps the parser will take +// to recover after encountering an error. func ParserErrorRecoveryLimit(limit int) EnvOption { return setLimit(limitParseErrorRecovery, limit) } diff --git a/common/env/env.go b/common/env/env.go index 7f5732e94..85ec85cd0 100644 --- a/common/env/env.go +++ b/common/env/env.go @@ -746,15 +746,19 @@ func (feat *Feature) Validate() error { return nil } +// Limit represents a named limit in the CEL environment. This is used to control +// the complexity tolerated before failing parsing, type checking, or planning. type Limit struct { Name string `yaml:"name"` Value int `yaml:"value"` } +// NewLimit creates a new limit. func NewLimit(name string, value int) *Limit { return &Limit{name, value} } +// Validate validates a limit. func (l *Limit) Validate() error { if l == nil { return errors.New("invalid limit: nil")