Skip to content
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

Add support for YAML encoded input documents #290

Closed
tsandall opened this issue Mar 8, 2017 · 2 comments
Closed

Add support for YAML encoded input documents #290

tsandall opened this issue Mar 8, 2017 · 2 comments

Comments

@tsandall
Copy link
Member

tsandall commented Mar 8, 2017

Currently OPA supports YAML encoded input documents via the command line but not as inputs to queries. It would be nice to be able to POST YAML inputs. The server has two helper functions that read the input from the request: readInputV0 and readInputV1. These functions should be extended to check the request header content-type (defaulting to util.Unmarshal if no header is supplied.)

@BenderScript
Copy link
Contributor

BenderScript commented Oct 13, 2018

I thought this would be useful and worked on a fix, but it turns out the changes needed are deeper than originally thought (although very doable).

The code today is very much hardwired to JSON everywhere. For example, although my changes allow input documents in YAML, the response comes back in JSON, which I am sure is not what a potential client would expect.

In order to send responses back in YAML (including explain, pretty, diag, etc) we would need to change v1DataPost() to either:

  • Produce everything in YAML and we write to yaml to response.writer
  • At the very end check if Content-Type is yaml and if yes, convert from JSON to yaml and write to response.writer
  • Others?

thanks

PS: I believe another discussion to have is whether we would want to support additional mime-types in the future

@tsandall
Copy link
Member Author

I'm less inclined to support YAML responses for the time being. I think that sending JSON responses is acceptable. Supporting YAML inputs is a nice-to-have when the policy input is a configuration file (e.g., a Kubernetes manifest.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants