Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
format: only use ref heads for all rule heads if necessary (#5450)
Before, we'd end up formatting ps["foo"] = "bar" { true } as ps.foo = "bar" { true } and older OPA version know how to parse the former, but not the latter. Fixes #5449. Also includes: * format: pass internal options via struct; because adding a third (in some cases fifth) boolean argument just didn't seem right. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
- Loading branch information
Showing
8 changed files
with
104 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package demo | ||
|
||
foo["bar"] = "baz" { input } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package demo | ||
|
||
foo["bar"] = "baz" { | ||
input | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This is the same as test_issue_5449.rego, but with another rule | ||
# that gives the formatter the assurance that using ref rules is OK | ||
package demo | ||
|
||
import future.keywords.contains | ||
|
||
foo["bar"] = "baz" { input } | ||
|
||
a.deep contains "ref" |
11 changes: 11 additions & 0 deletions
11
format/testfiles/test_issue_5449_with_contains_ref_rule.rego.formatted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This is the same as test_issue_5449.rego, but with another rule | ||
# that gives the formatter the assurance that using ref rules is OK | ||
package demo | ||
|
||
import future.keywords.contains | ||
|
||
foo.bar = "baz" { | ||
input | ||
} | ||
|
||
a.deep contains "ref" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This is the same as test_issue_5449.rego, but with a rule that gives | ||
# the formatter the assurance that using ref rules is OK | ||
package demo | ||
|
||
foo["bar"] = "baz" { input } | ||
|
||
a.deep.ref := true |
9 changes: 9 additions & 0 deletions
9
format/testfiles/test_issue_5449_with_ref_rule.rego.formatted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This is the same as test_issue_5449.rego, but with a rule that gives | ||
# the formatter the assurance that using ref rules is OK | ||
package demo | ||
|
||
foo.bar = "baz" { | ||
input | ||
} | ||
|
||
a.deep.ref := true |