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