mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
d36655f5fb
`opa fmt` isn't idempotent for rules it can't write on a single line:
the first pass runs the rule together with the one that follows, and
only a second pass inserts the missing blank line.
Given this policy:
```rego
package example
allow if { {"admin", "dev"} }
deny if input.blocked
```
`opa fmt` produces output that it doesn't consider formatted:
```rego
package example
allow if {
{"admin", "dev"}
}deny if input.blocked
```
```console
$ opa fmt --fail example.rego; echo $?
2
```
Running it a second time inserts the blank line and settles:
```rego
package example
allow if {
{"admin", "dev"}
}
deny if input.blocked
```
with this fix fmt goes to the second result immediately
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>