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

compile: add WithRoots compiler option #6085

Closed
kubaj opened this issue Jul 10, 2023 · 3 comments · Fixed by #6088
Closed

compile: add WithRoots compiler option #6085

kubaj opened this issue Jul 10, 2023 · 3 comments · Fixed by #6088

Comments

@kubaj
Copy link
Contributor

kubaj commented Jul 10, 2023

What is the underlying problem you're trying to solve?

I'd like to build an OPA bundle from Go using the compile API (github.com/open-policy-agent/opa/compile) but it's missing the support for providing bundle roots. I've tried to find some workaround for this, but I wasn't successful.

Describe the ideal solution

Ideal situation would be that Go compile API has the same options when building OPA bundles as the OPA CLI's build command.

Describe a "Good Enough" solution

Adding WithRoots compiler option used for specifying bundle's roots.

@ashutosh-narkar
Copy link
Member

I'd like to build an OPA bundle from Go using the compile API (github.com/open-policy-agent/opa/compile) but it's missing the support for providing bundle roots.

Have you tried using WithPaths with WithAsBundle enabled? I think this should allow you specify the bundle manifest.

@kubaj
Copy link
Contributor Author

kubaj commented Jul 11, 2023

I've tried this combination but based on error I've got:

load error: bundle policy.rego: bundle read failed: archive read failed: gzip: invalid header"

it looked that this option is used when you want to use the content of the already existing bundle to build the bundle. (e.g. combine multiple bundles together).

@ashutosh-narkar
Copy link
Member

Let's say you have a folder with your policy, data and manifest file. Are you saying if you set WithPaths to point to that with bundle mode enabled, you get an error?

Adding a WithRoots option seems fine btw. If you'd like to contribute that would be great!

kubaj pushed a commit to kubaj/opa that referenced this issue Jul 12, 2023
Previously, bundle roots couldn't be provided and neither .manifest file couldn't be provided, because it was replaced by the .manifest generated by the compiler.

Fixes: open-policy-agent#6085

Signed-off-by: Jakub Kulich <jakubkulich@gmail.com>
kubaj added a commit to kubaj/opa that referenced this issue Jul 12, 2023
Previously, bundle roots couldn't be provided and neither .manifest file couldn't be provided, because it was replaced by the .manifest generated by the compiler.

Fixes: open-policy-agent#6085

Signed-off-by: Jakub Kulich <jakubkulich@gmail.com>
kubaj added a commit to kubaj/opa that referenced this issue Jul 14, 2023
Previously, bundle roots couldn't be provided and neither .manifest file couldn't be provided, because it was replaced by the .manifest generated by the compiler.

Fixes: open-policy-agent#6085

Signed-off-by: Jakub Kulich <jakubkulich@gmail.com>
ashutosh-narkar pushed a commit to kubaj/opa that referenced this issue Jul 14, 2023
Previously, bundle roots couldn't be provided and neither .manifest file couldn't be provided, because it was replaced by the .manifest generated by the compiler.

Fixes: open-policy-agent#6085

Signed-off-by: Jakub Kulich <jakubkulich@gmail.com>
ashutosh-narkar pushed a commit that referenced this issue Jul 14, 2023
Previously, bundle roots couldn't be provided and neither .manifest file couldn't be provided, because it was replaced by the .manifest generated by the compiler.

Fixes: #6085

Signed-off-by: Jakub Kulich <jakubkulich@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants