-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indented/"pretty-printed" JSON marshaling #6630
Comments
Updating the existing builtin would be backwards-incompatible. A new |
@ashutosh-narkar Does Rego/OPA support polymorphic functions/optional parameters? Part of the rationale behind adding a new optional parameter was so any existing [one-parameter] calls to |
Currently not. Only |
…ty-printed" and/or line-prefixed JSON (open-policy-agent#6636) Fixes open-policy-agent#6630 Signed-off-by: Sean Williams <72675818+sean-r-williams@users.noreply.github.com> Signed-off-by: Thomas Sidebottom <thomas.sidebottom@va.gov>
What is the underlying problem you're trying to solve?
We're using SpaceLift for automating Terraform management. SpaceLift uses OPA for notification policies, which determines when (and what) to comment on PRs to SpaceLift-connected repos.
Presenting contextual plan output (i.e. new resource state) is easiest by serializing the state object to JSON. (This is what one of the examples in the Spacelift docs suggests.) However, both interpolating the object via
sprintf
or usingjson.marshal
both produce compressed, single-line JSON. This is hard for human readers to interpret.Describe the ideal solution
Add an optional Boolean parameter to
json.marshal()
(defaulting to false) that indicates the resultant JSON string should be indented.Describe a "Good Enough" solution
Add a new built-in (e.g.
json.marshal_indent()
that functions identically tojson.marshal
, but with indented/multi-line output.Additional Context
The text was updated successfully, but these errors were encountered: