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

Function parseAndCompilePolicy

policy/compiler_test.go:261–275  ·  view source on GitHub ↗
(t testing.TB, name string, policySource string, envOpts []cel.EnvOption, compilerOpts []CompilerOption)

Source from the content-addressed store, hash-verified

259}
260
261func parseAndCompilePolicy(t testing.TB, name string, policySource string, envOpts []cel.EnvOption, compilerOpts []CompilerOption) (*cel.Env, *cel.Ast, *cel.Issues) {
262 t.Helper()
263 policy := parsePolicySource(t, name, policySource)
264 envOpts = append([]cel.EnvOption{
265 cel.OptionalTypes(),
266 cel.EnableMacroCallTracking(),
267 ext.Bindings(),
268 }, envOpts...)
269 env, err := cel.NewEnv(envOpts...)
270 if err != nil {
271 t.Fatalf("cel.NewEnv() failed: %v", err)
272 }
273 ast, iss := Compile(env, policy, compilerOpts...)
274 return env, ast, iss
275}
276
277func newRunner(name, expr string, parseOpts []ParserOption, envOpts ...cel.EnvOption) *runner {
278 return &runner{

Calls 6

OptionalTypesFunction · 0.92
EnableMacroCallTrackingFunction · 0.92
BindingsFunction · 0.92
NewEnvFunction · 0.92
parsePolicySourceFunction · 0.85
CompileFunction · 0.70

Tested by

no test coverage detected