forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update format package to tolerate nil locations
Previously, the format package would return an error if any of the AST nodes under the input were missing a location value. When the format package was first implemented, the main use case was formatting policies that people had written manually--which means they are provided to OPA as files/raw strings. As a result, it made sense to treat a missing location as an error condition because it simplifies the formatting implementation. However, when policies are generated (e.g., by partial evaluation) the AST nodes do not typically carry locations. As a result, these AST nodes cannot be formatted nicely. These changes modify the format package to tolerate nil location values. If a nil location value is encountered, the format package will set the location value on the AST node to a default location, currently row 1 column 1 with text from the AST node's string representation. Signed-off-by: Torin Sandall <[email protected]>
- Loading branch information
Showing
6 changed files
with
163 additions
and
96 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
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
Oops, something went wrong.