-
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
Running opa using a bundle doesn't work likewise doing it with the equivalent folder #1019
Comments
It seems the main issue here is that the data.json file is not being read out of the bundle (for some reason, this seems to be a bug.) Other than that, if you run commands from the directory containign "parent" things should work:
|
When I running from a the bundle everything is contained in the parent folder (
Which is not the way it shows to you, which is weird: In your case running opa on the folder takes
|
@EliuX can you include the output of something like |
The content of the bundle
|
Can you post similar output for the non-bundle case? In my case I put the |
Previously, the bundle reader code would only load data.json files prefixed with / characters. This meant that if the data file was located under a subdirectory it would load fine in all cases, but if it was contained at the root, the tar file would have to be written to include the slash prefix. By default running tar on a directory will not do this--which meant that data.json files would not be picked up if the bundle was created using the tar command. These changes modify the bundle reader to accept data.json files in all of these cases. The behaviour between opa run . and opa run bundle.tar.gz is consistent regardless of whether the bundle was written by OPA or by tar. Also, since the file extensions are not used outside of the bundle package, unexport them. Fixes open-policy-agent#1019 Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Previously, the bundle reader code would only load data.json files prefixed with / characters. This meant that if the data file was located under a subdirectory it would load fine in all cases, but if it was contained at the root, the tar file would have to be written to include the slash prefix. By default running tar on a directory will not do this--which meant that data.json files would not be picked up if the bundle was created using the tar command. These changes modify the bundle reader to accept data.json files in all of these cases. The behaviour between opa run . and opa run bundle.tar.gz is consistent regardless of whether the bundle was written by OPA or by tar. Also, since the file extensions are not used outside of the bundle package, unexport them. Fixes #1019 Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Sorry for the late response @tsandall. Well the content of the bundle is pretty much the content of the folder, except for the test rego files. For that folder I run |
Problem
When I run
opa
in server mode using a system folder that looks like:All tests run OK and the opa server understand the data namespace (queried with a GET
http://localhost:8181/v1/data
) asHave in count that the data.json looks like:
So this is the way I expected in my code for this to work. So far so good.
The problem comes when I compress the parent folder with:
tar --exclude='*_test.rego' -zcvf parent.tar.gz parent
when I query the running server using
GET http://localhost:8181/v1/data
I realize that all mydata.json
content was moved into theparent
package:So I tried again creating a bundle file that doesn't contain the parent folder:
Runned
opa
in server mode again and realized this time the data.json was not even presentSo basically I realized that I had to create a bundle containing the
data.json
contained in a folder, but even in that case for the bundle to work I should do one of the following workarounds:data.parent.organizations
instead ofdata.organizations
.data.json
to thedm
package, but the problem persists because when I run it using the bundle I get something like:but using the folder directly I get something like
So the workaround seems to be a change of code again.
Analysis
It doesn't seem a good idea to use 2 versions of the same code, one for running
opa
in server mode with a folder and another for a bundle, having both the same structure. It would be nice that if you runtar --exclude='*_test.rego' -zcvf parent.tar.gz parent
to anyparent
folder you get a bundle that runs likewise running it using the folder directly.The text was updated successfully, but these errors were encountered: