-
Notifications
You must be signed in to change notification settings - Fork 309
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
No caching for HTTP requests #1045
Comments
This can be added, but I'd like to better understand the problem first. Why is it an issue that the call is made twice? |
Hey @jalseth ! Thanks for the reply. I think i meant the |
Adding rego.InterQueryBuiltinCache(cache.NewInterQueryCacheWithContext(ctx, nil)), at the end of the list of options here, should be enough (if no particular configuration / limit needs to be set). |
Thanks for clarifying. I don't have any problem with adding the cache to the |
Hi!
This question was also posted in slack on 13th of january.
It seems Conftest does not support or do any caching for
http.Send()
requests, whilst OPA does.I currently have a rule that needs to call an API endpoint to verify data against, e.g. see if the value in the YAML is in the list of values from the API endpoint.
Now to not be too tightly coupled with the API we want to check if the status code is 200 or not. If not, we put out a
warn_
otherwise we actually evaluate adeny_
rule. This is to prevent failures if the API is down or any other network issue for example.I tried a local setup with a simple http server in go exposing an endpoint and logging each hit on it.
And i have the following policy:
When running this with
conftest verify
hits my http endpoint twice. Withopa eval
it only gets hit once.Now hitting it twice is actually exactly what we dont want (the
warn_
eval can succeed but thedeny_
eval can error out and thus fail).Is there reasoning for not doing caching on http requests?
If there is an actual reason for not doing caching, is there a way to handle this scenario?
Please let me know if you need more info/debugging! Happy to help. In the meantime, if i have the time, i might dive into the source to see if i can contribute myself!
The text was updated successfully, but these errors were encountered: