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

cmd & format: Adding rego-v1 mode to opa fmt #6413

Merged
merged 14 commits into from
Nov 30, 2023

Conversation

johanfylling
Copy link
Contributor

@johanfylling johanfylling commented Nov 15, 2023

Adding --rego-v1 flag to opa fmt command.

Calls to deprecated built-ins are not rewritten to equivalent v1-compliant code; we can add this separately.

Fixes: #6297

Fixes: open-policy-agent#6297
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
* duplicate imports
* data/input root document overrides
* deprecated built-in usage

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Copy link

netlify bot commented Nov 15, 2023

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 463fcf7
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/656858d3a71d13000869d28d
😎 Deploy Preview https://deploy-preview-6413--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@johanfylling johanfylling marked this pull request as ready for review November 15, 2023 14:05
@@ -0,0 +1,112 @@
package ast
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're now exposing internal compiler logic here. Should be put this in an internal package instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that, but since we also need to call this from the compiler which lives in the ast package which is heavily used from these functions, we get a circular import that fails compilation.
If there aren't clever ways around that, I suppose the alternative is to duplicate the functionality, so it can be used both in the compiler and in the formatter without making it public.

Perhaps the lesser evil is to eat the redundancy and not make this public .. I don't know 🤔. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say let's try to minimize the replication as much as we can. Exposing these methods does not seem like a good idea. Moving them to an internal package will require a lot of refactoring.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Conflicts:
	ast/compile.go
Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The test coverage is really good. On rewriting of the deprecated built-ins, if you could create an issue to track this work that would be great!

@johanfylling
Copy link
Contributor Author

#6445

@johanfylling johanfylling merged commit 187d688 into open-policy-agent:main Nov 30, 2023
24 checks passed
@johanfylling johanfylling deleted the rego-v1/fmt branch November 30, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add mode to OPA format to migrate to strict mode complaint code
2 participants