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)
| 256 | // This generates a single CEL AST from a collection of policy expressions associated with a |
| 257 | // CEL environment. |
| 258 | func 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 |