Skip to content
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

Imports of specific rule from module not supported #270

Closed
stek29 opened this issue May 4, 2022 · 2 comments · Fixed by #286
Closed

Imports of specific rule from module not supported #270

stek29 opened this issue May 4, 2022 · 2 comments · Fixed by #286
Labels
bug Something isn't working

Comments

@stek29
Copy link
Contributor

stek29 commented May 4, 2022

Importing specific rule from module is not supported – dependencies fail to resolve and konstraint create fails.

For example, having import lib.core.missing_field in policy should resolve that to "import missing_field from lib.core" instead of "import missing_field from lib/core/missing_field.rego" and failing.

@jalseth jalseth added the bug Something isn't working label May 5, 2022
@jalseth
Copy link
Collaborator

jalseth commented May 5, 2022

Thanks for raising this. Using the import keyword in this manner isn't very common in the Rego policies I've seen. Given that the import keyword is only an alias and does not affect the scope of what is loaded or the runtime performance, it seems a reasonable work-around for now is to import the entire package and then invoke the rules using the package prefix ex core.missing_field() rather than missing_field().

If you have the time, I'd be happy to review a PR. If you plan on working on this please assign the issue to yourself so we don't duplicate any effort.

@stek29
Copy link
Contributor Author

stek29 commented May 5, 2022

@jalseth I've seen it being used in Gatekeeper examples and Gatekeeper policy library iirc
I'm not sure on what'd be the best way to implement this, so I probably won't be submitting PR for this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants