open-policy-agent/conftest

Add support for adding built-in functions

Closed this issue · 2 comments

lcarva commented

Hello!

I'm one of the maintainers of the Enterprise Contract CLI. We use the conftest runner to evaluate rego policies. This is more beneficial to us than using opa directly.

We have certain requirements that could be met by using custom built-in functions.

Would you be open to extending the TestRunner API to support this? If so, I'm happy to provide a patch!

If you are using conftest as a library, I don't think you need to modify conftest to add new builtins. The builtins are globally namespaced. You can register builtins using rego.RegiserBuiltin{1..4} which will be used by the conftest runner. You can see some examples of builtins Conftest adds to the OPA engine in https://github.com/open-policy-agent/conftest/blob/master/builtins/parse_config.go.

lcarva commented

@jalseth, thanks! I wasn't aware of that. I have just verified that it works as expected.