projectcontour / integration-tester

Integration Tester for Kubernetes
Other
3 stars 5 forks source link

Builtins are missing from initial policy loader #22

Closed jpeach closed 3 years ago

jpeach commented 3 years ago

What steps did you take and what happened:

If you add a policy file that references a builtin package, it errors on startup:

$ ./run-test-case.sh --trace=rego --preserve ./httpproxy/015-http-health-checks.yaml
integration-tester: 2 errors occurred:
/Users/jpeach/upstream/contour/_integration/testsuite/policies/contour-expect.rego:22: rego_type_error: undefined function data.builtin.result.Passf
/Users/jpeach/upstream/contour/_integration/testsuite/policies/contour-expect.rego:24: rego_type_error: undefined function data.builtin.result.Errorf

This happens in loadPolicies where we validate that the Rego policy files compile before building the option to pass them down into the test runner. We need to load the builtins first (and not export them to the option) (the runner does this, so we could consolidate that code).