-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OPA Constraint Template - Query Regarding OPA Custom Function Usage Across Multiple ConstraintTemplates #3831
Comments
As of not CT can only execute the code defined in rego and lib fields. Importing code outside of the ConstraintTemplate is not allowed. This might help you get some more context - #3558 (comment) on how to reuse common functions. |
Can we have common Functions in separate .rego file. And is there any way we can use the functions from .rego file in constraint template files. Suggest Any other ways to reuse the code/common Functions across all constraint template files. |
@dore-0803 You can look at how gatekeeper library constructs constraint template with having a src.rego file and implement something similar according to your use case. |
Hi, https://github.com/open-policy-agent/gatekeeper-library/tree/master/src/general/allowedreposv2 tha above code is not working. i just applied constraint.tmpl , $ kaf constraint.tmpl when i checked the logs it gave the below error.
is there any other way to use common functions in separate file(.rego or any other). and use it across all constraint templates. |
Hi Team,
I have a question regarding the usage of custom functions in OPA.
How can I use a function defined in A-ConstraintTemplate.yaml within B-ConstraintTemplate.yaml?
For instance, if we have 10 policies, I would like to write common utility functions only once and reuse those functions across all policies. How can this be achieved?
request you to provide your inputs.
thanks.
The text was updated successfully, but these errors were encountered: