MCPcopy Create free account
hub / github.com/cel-expr/cel-go / Compile

Function Compile

policy/compiler.go:258–266  ·  view source on GitHub ↗

Compile combines the policy compilation and composition steps into a single call. This generates a single CEL AST from a collection of policy expressions associated with a CEL environment.

(env *cel.Env, p *Policy, opts ...CompilerOption)

Source from the content-addressed store, hash-verified

256// This generates a single CEL AST from a collection of policy expressions associated with a
257// CEL environment.
258func Compile(env *cel.Env, p *Policy, opts ...CompilerOption) (*cel.Ast, *cel.Issues) {
259 rule, iss := CompileRule(env, p, opts...)
260 if iss.Err() != nil {
261 return nil, iss
262 }
263 // An error cannot happen when composing without supplying options
264 composer, _ := NewRuleComposer(env)
265 return composer.Compose(rule)
266}
267
268// CompileRule creates a compiled rules from the policy which contains a set of compiled variables and
269// match statements. The compiled rule defines an expression graph, which can be composed into a single

Callers 4

CreateASTMethod · 0.92
TestSimpleVariablesFunction · 0.70
parseAndCompilePolicyFunction · 0.70
compileFunction · 0.70

Calls 4

ComposeMethod · 0.95
CompileRuleFunction · 0.85
NewRuleComposerFunction · 0.85
ErrMethod · 0.80

Tested by 3

TestSimpleVariablesFunction · 0.56
parseAndCompilePolicyFunction · 0.56
compileFunction · 0.56