-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve support for file loading in large workspaces #1087
Comments
/cc @teq0 if you have further thoughts on how to implement this, feel free to post on Slack or here. |
Not sure about the whitelist part, but in the loader there's already the concept of filters, but at the moment filters appear to implemented one at a time, even though there's an It seems like the simplest approach would be to substitute The thing I don't have a good handle on is how to inject a fake .opaignore for testing purposes. And I'm not sure of the use case for the whitelist. To include specific files in folders that are blacklisted? |
The code in the loader basically runs
See the loader_test.go file, there are a bunch of integration tests there that set up a temporary filesystem (and do cleanup properly). You could add another test case to exercise this.
The use case for whitelisting is when policies are kept in a monorepo and you have an IDE/workspace that loads the whole monorepo. In this world, blacklists are a pain to maintain. It's easier to say:
This is how gitignore works. Hope this helps! |
Got it. So after https://github.com/open-policy-agent/opa/blob/master/loader/loader.go#L236 call another filter that checks against the .opaignore rules. And I get the WithTempFS() now. |
Yes, I suppose that caller filters should override the .opaignore rules, so the caller filters should run first. One thing to keep in mind/test is that --ignore should not cause the loader to ignore .opaignore files themselves. One of the main reasons we added --ignore in the first place was to let users ignore dotfiles (there is some odd behaviour when you volume mount configmaps in kubernetes that results in the configmap contents being duplicated under the volume mount directory.) Looking forward to getting this into OPA. |
There are a few go implementations of .gitignore functionality, is it OK if I vendor one in rather than writing yet another one? If so, do you have a preference, or any guidelines for picking one? |
@teq0 It's fine to vendor as long as:
|
Just an update, I have it working, the actual code isn't that much, I'm a bit stuck on getting tests to work though and I've been a bit time poor. But it's coming... |
Great! If you get it to a point where you'd like to be done and want to hand it off, feel free to send me the patch and I can finish it off (with you as the git author.) |
With the new parser we released last year and the fact that |
It should be possible to easily run tools like
opa run
oropa eval
oropa test
in workspaces that contain many files, e.g., mono repos. Currently tools likeopa run
load all JSON and .rego files out of the provided directories, recursively. In large workspaces like mono repos this can be quite expensive.One option would be introduce support for an
.opaignore
file that users could configure to control file loading. The.opaignore
file could include both blacklist and whitelist directives. For example:This would ignore all files and then explicitly load files under the path
policies
.To implement this we could update the loader package to look for the
.opaignore
file and then alter loading behaviour accordingly.The text was updated successfully, but these errors were encountered: