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

Method compileRule

policy/compiler_test.go:313–332  ·  view source on GitHub ↗
(t testing.TB)

Source from the content-addressed store, hash-verified

311}
312
313func (r *runner) compileRule(t testing.TB) (*cel.Env, *CompiledRule, *cel.Issues) {
314 t.Helper()
315 config := readPolicyConfig(t, fmt.Sprintf("testdata/%s/config.yaml", r.name))
316 policy := parsePolicy(t, r.name, r.parseOpts)
317 env, err := cel.NewCustomEnv(
318 cel.OptionalTypes(),
319 cel.EnableMacroCallTracking(),
320 cel.ExtendedValidations(),
321 ext.Bindings())
322 if err != nil {
323 t.Fatalf("cel.NewEnv() failed: %v", err)
324 }
325 // Configure declarations
326 env, err = env.Extend(FromConfig(config))
327 if err != nil {
328 t.Fatalf("env.Extend() with config options %v, failed: %v", config, err)
329 }
330 rule, iss := CompileRule(env, policy)
331 return env, rule, iss
332}
333
334func (r *runner) setup(t testing.TB, env *cel.Env, ast *cel.Ast) {
335 t.Helper()

Callers 1

TestRuleComposerUnnestFunction · 0.45

Calls 10

NewCustomEnvFunction · 0.92
OptionalTypesFunction · 0.92
EnableMacroCallTrackingFunction · 0.92
ExtendedValidationsFunction · 0.92
BindingsFunction · 0.92
readPolicyConfigFunction · 0.85
parsePolicyFunction · 0.85
CompileRuleFunction · 0.85
FromConfigFunction · 0.70
ExtendMethod · 0.45

Tested by

no test coverage detected