-
Notifications
You must be signed in to change notification settings - Fork 451
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 --yaml-stream #117
Add --yaml-stream #117
Conversation
My comment would be that it seems like a lot of change (and modifies very internal components). Unlike multi this could be implemented in a couple lines of jsonnet and -S:
The requirement seems very similar to the requirement to output .ini, but the implementation and api is quite different. I'll call a "finalizer" a single final function that get's called on the output of a jsonnet program. I've seen three use cases for "finalizers" so far:
I'm sure there will be more. Is it worth it or possible to design a reasonable and generic API for finalizers? That said, if the api existed, it would be easy to move the cli API over to it and even the c API deprecating the functions added here. |
What is the use case for this? |
@davidzchen The use case is basically Kubernetes. But the YAML stream format is a standard. @mikedanese Good point, this could at least be implemented in the desugarer and by enabling -S with -y. What you're calling a finalizer is exactly what I've been calling manifestation though I think. It's a final step that converts a value to a string. OK the semantics actually says convert a Jsonnet value to a JSON value by forcing thunks, bindings objects, and stripping hidden fields. But It could just as easily say "call the std.manifestJson function and get a string". So should we be able to specify a jsonnet file on the commandline and that would define the manifestation function? |
|
So you desugar jsonnet --manifest=M -e E to M(E) The old -S behavior is now --manifest=function(x)x |
Here's a challenge with this though: If you do
Then you get
Which has the very useful piece of contextual information test.jsonnet:(10:8)-(12:5) that lets us know where we instantiated the bad X from. However if you use std.manifestJson (which I just wrote), you get:
Which lacks that information. This problem already existing with std.manifestPython of course but JSON is the common case here. Some solutions:
|
Catching and rethrowing would have to preserve the stack trace as well, so there's some design work there. |
@davidzchen @mikedanese