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
Adds std.parseYaml #888
Adds std.parseYaml #888
Conversation
Great! I need to read it carefully. It adds so many files, Github won't even display the table of contents....
Does the Go version support it? We would like to avoid major differences if possible. (We can never guarantee full parity, but we should be compatible when it comes to big and obvious stuff).
Do we have tests for parseYaml? It's especially important for checking compatibility between implementations.
We'll need to add that, but we can wait until we decide which yaml implementation we will use. It shouldn't be a big deal. |
Yes. Apologies. I wasn't sure which approach I should take when I vendored the third_party code, so I've kept 99% of it, even though not all of it is required. If we only need to support Bazel, I could probably get it to work using a repository rule like The main changes I would suggest to orient yourself around the PR:
Yes, it does. Originally the go-jsonnet implementation I proposed pulled in Perhaps a demonstration will make things clearer.
I agree. We definitely should make it clear that yaml support is best effort, but for things such as single vs multiple documents, there should be parity. Perhaps there needs to be a different API for single vs multiple yaml document parsing? Not sure what your appetite is for this, but if we do implement something on the CPP side, we could perhaps use the same CPP implementation on the go-jsonnet side if we create a small
Some very basic tests to kick the tyres: Similar or more can and should be added to the go-jsonnet implementation of
Agree. Thanks! |
Similar demo output for the CPP implementation.
As mentioned above, no multidoc support at the moment. |
I got an error when compiling without optimization:
Probably it needs to be added as an explicit dependency if we go with Rapidyaml.
Yes. I think this is the best approach.
In this case probably not. It tends to be a bit of a pain with Bazel (with go-jsonnet we have a submodule setup and a separate download-tar-over-http setup for sharing cpp-jsonnet test suite etc.). This is supposed to be pretty stable, so updating it manually every now and then should be enough.
Not worth it. Mostly, because it makes updating the vendored version harder.
Hmmm... Python has
Sounds complicated. Also, it should be possible for third parties to achieve the same level of parity as the official implementations. We don't want to depend too much on specific library being used. With YAML we'll have to accept differences in some "dark corners". As long as we can get the same result in obvious cases, I'll be happy.
We run go-jsonnet against cpp-jsonnet tests, so it's enough to add some here. If we're going to test any error cases, we may need to override their results for go-jsonnet (we have a mechanism for that).
Yeah. The point is not testing the underlying YAML implementation for subtle differences, but just verifying that the thing actually works and doesn't have any interface quirks (e.g. that it handles various top-level types correctly). |
Thanks for the review!
I can add this dependency as well 👍
Ok, if I go this route, what is the plan for CMake and Make? Work that out after we get the Bazel version implemented?
Ok, I think we can have more discussions on details later. As long as they're consistently applied in both CPP and Go it should be fine. Ok, it all sounds fine to me. I may not have much time soon to work further on this, but I think my next steps will be:
Then we can discuss any further outstanding questions. |
This is perfectly fine, there's no rush. In case you need to drop this completely, please let me know, so I can pick this up.
I was referring to copy-paste approach in the last sentence. Sorry I didn't make it more explicit. So, we'll leave the vendored version and we'll have no problem in any build system. There's also less work, since it's basically what you already did.
We can work out the details after we have Bazel working. Since everything is vendored it should be quite easy. |
Ah, ok. Got it. So then my plan will change to:
|
Sounds good! |
TODO
|
If the YAML document is a single document with a top-level object, a jsonnet object is returned. If the document is a YAML stream, with multiple top-level objects, a jsonnet array is returned. This behaviour seems correct to me. It does currently differ from my go-jsonnet PR, so that should be updated to match this behaviour. See below for details:
|
PTAL @sbarzowski |
Looks good. Sorry for the delay. Now we just need to make sure it works with all build systems. |
Thanks! I'd appreciate any help here. My Some news, I've tested I tested against ~3k lines of YAML in-the-wild from vendors such as AWS, kubernetes cluster autoscaler, datadog, weaveworks and bitnami and it was able to parse them successfully, so that gives me some comfort that it will work against the popular YAML formats out there. |
Sure. I don't know how you want to go about it. Do you want to give it a try (I can see you added the CMake thing)? I can help if you get stuck. I can also just pick it up from here. Please let me know how I can help.
That's great! |
I would definitely appreciate it if you gave it a try. CMake is a big mystery to me. I tried it, but I'm not sure that it works correctly. This is failing:
However, this appears to compile everything and runs the tests:
🤷 |
Ok, so I'll handle the build systems. With some luck, I'll be able to do it this weekend. |
Update: I started working on this form the Makefile side. I doesn't work so far and it's not officially supported (only CMake is), but it doesn't seem to difficult. I'll update here when I have something concrete. |
Any news on this @sbarzowski ? |
I got it to work for the most part: #899. Ran into some stupid issues unrelated mostly unrelated to the core change (about available compiler version in Travis). The Makefile part is a bit hacky, but should work fine. CMake required removing a small part of upstream CMakeLists.txt to make it work (167113c#diff-399a771633b7813f785ae66df1d986e82aec414cab5a33cf22e99df04a5354abL68). |
Ok! Great! Any next steps? |
I just need to do more trial and error to get it to pass. I'm wondering how to handle submitting this. There are two ways. Either you'll incorporate my changes in your PR or I need your consent in #899. Either way I'll squash all commits into one with you as the author. Also, sorry it's taking me so long. I've been a bit overwhelmed by other obligations. |
Totally understand. Finding time for open source is difficult. It took me ages to find some moments to work on this as well. Just let me know if there is any way I can help. In terms of submitting all this once we've got the necessary things working, I don't mind how we do it. I can include your changes into the original PR, or you can do a new one with #899. |
@sbarzowski Is there anything I can do to assist? |
It was submitted in #899 (it's basically this PR + a few build system fixes). Thank you very much for implementing this much needed feature and for your patience! |
It really has been a journey! 😄 Thanks for your help and support. |
Adds std.parseYaml to address the YAML aspect of: #460
go-jsonnet implemented here: google/go-jsonnet#339