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

Function Compile

policy/compiler.go:244–252  ·  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

242// This generates a single CEL AST from a collection of policy expressions associated with a
243// CEL environment.
244func Compile(env *cel.Env, p *Policy, opts ...CompilerOption) (*cel.Ast, *cel.Issues) {
245 rule, iss := CompileRule(env, p, opts...)
246 if iss.Err() != nil {
247 return nil, iss
248 }
249 // An error cannot happen when composing without supplying options
250 composer, _ := NewRuleComposer(env)
251 return composer.Compose(rule)
252}
253
254// CompileRule creates a compiled rules from the policy which contains a set of compiled variables and
255// match statements. The compiled rule defines an expression graph, which can be composed into a single

Callers 3

CreateASTMethod · 0.92
TestSimpleVariablesFunction · 0.85
compileFunction · 0.85

Calls 4

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

Tested by 2

TestSimpleVariablesFunction · 0.68
compileFunction · 0.68