Skip to content

v0.16.0

Compare
Choose a tag to compare
@github-actions github-actions released this 05 Feb 12:55
· 430 commits to main since this release
bc27c76

This release adds 2 new linter rules and a language server protocol (LSP) implementation to Regal.

New rule: duplicate-rule

Category: bugs

The new duplicate-rule linter rule flags any rules with duplicated code found in a policy. Duplicate rules are almost certainly a mistake, perhaps from copy-pasting code, and should simply be fixed (or likely, removed).

For more information, see the docs on duplicate-rule.

New rule: use-rego-v1

Category: imports

OPA v0.59.0 introduced a new import named rego.v1. When import rego.v1 is used in a policy, OPA will ensure the policy is compliant with the upcoming OPA 1.0 release. This include enforcing the use of the if and contains keywords, that no deprecated built-ins are used, and more. To learn more about OPA 1.0 and the rego.v1 import, see the OPA docs.

As rego.v1 replaces the future.keywords imports, the Regal rules around those imports are automatically disabled when use-rego-v1 is in use. If you wish to target a version of OPA before rego.v1, use the capabilities feature of the Regal configuration file.

Avoid

package policy

# before OPA v0.59.0, this was best practice
import future.keywords.contains
import future.keywords.if

report contains item if {
    # ...
}

Prefer

package policy

# with OPA v0.59.0 and later, use this instead
import rego.v1

report contains item if {
    # ...
}

For more information, see the docs on use-rego-v1.

New feature: Regal language server

The Language Server Protocol (LSP) provides a way for editors to integrate support for various programming languages using a common protocol. Using an LSP server implementation rather than one built specifically for a single editor allows the same code to be used across all editors with LSP support. v0.16.0 brings a language server mode to Regal, allowing diagnostics (i.e. linting) of Rego to be performed continuously in a workspace rather than as a one-off CLI operation. This is the first step towards bringing Regal into editors like VS Code, and having linting of Rego natively supported as you work with your policies. Expect to see more in this space soon!

Huge thanks to @charlieegan3 for this outstanding contribution!

Changelog