timbertson / dhall-render

Render multiple files from dhall expressions
BSD Zero Clause License
18 stars 7 forks source link

dhall-render: Added support for YAML stream documents #5

Closed davidreuss closed 3 years ago

davidreuss commented 3 years ago

Kubernetes and yaml stream/multi documents sitting in a 🌴

Support writing this type if the contents input is a list, with each document encoded.

I'm not sure if psych is the right module to work here, but it worked out of the box for me.

Feel free to use some other module if there's any you prefer.

timbertson commented 3 years ago

Thanks, I've tweaked this a bit in https://github.com/timbertson/dhall-render/commit/f10494d09ebec352ca7a22888e6401e4d28ae8db.

I figure an actual single-document yaml with a toplevel array is rare enough that we can just always treat it as a multi-doc rather than calling it a different format. You can always print a JSON doc with a .yaml extension if you really need a raw toplevel array 🤷

I did have to use Psych.dump_stream(*contents) (note the *), otherwise I just got a single-document with an array in it. But with the star, you get this which I assume is what you're after.