StyraInc / regal

Regal is a linter for Rego, with the goal of making your Rego magnificent!
https://docs.styra.com/regal
Apache License 2.0
237 stars 30 forks source link

Handle "pure" v1 files and projects/workspaces #651

Open johanfylling opened 2 months ago

johanfylling commented 2 months ago

When using the --v1-compatible flag with OPA, it'll behave exactly as v1.0 OPA. Meaning a Rego file isn't required to use the rego.v1 and future.keywords imports; e.g.:

package demo

p contains "Hello" if {
    input.x == 2
}

It'd be nice if Regal could be somehow instructed to deal with such files without errors or warnings.

One possible, non-obtrusive solution that would work with at least a subset of Rego projects would be to pick up the .manifest file in the workspace, and read the rego_version and file_rego_versions attributes (will be available in OPA v0.64.0).

anderseknert commented 2 months ago

Adding a --v1-compatible flag to regal lint seems easy enough, so let's do that. Looking for a .manifest file and use that seems like a good idea too if that's what OPA will be doing, and we can probably borrow some logic around that from OPA directly.

A PR would be welcome ;)

anderseknert commented 2 weeks ago

@johanfylling is there a capability to read for this? Regal already provides the option to provide capabilities via config, so that'd be a convenient way of doing it.