-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Yaml multiline string pretty-printing in manifestification #144
Comments
serde-yaml here is only used for parsing, manifestification is implemented manually, the same way as it implemented in official jsonnet: https://github.com/CertainLach/jrsonnet/blob/master/crates/jrsonnet-stdlib/src/manifest/yaml.rs#L110 It should be possible to implement different string manifestification strategy, but this should be also proposed/implemented on https://github.com/google/jsonnet side. |
We get a much better manifestation from kubecfg, which is a go program sitting on top of the go jsonnet and doing https://github.com/kubecfg/kubecfg/blob/main/pkg/kubecfg/show.go#L159-L171 - I think we'd be happy to do a similar shim on top of jrsonnet if we need to, but since producing config files at scale is a key use case, and since readability when doing code review matters - on the output - it would be great if you can suggest some way forward that involves somewhat less redundancy :) |
I'll think about this, I might add this feature under the feature-flag, because I agree such multiline string output is much better. I want jrsonnet to be mostly output-compatible with go-jsonnet. I won't make it worse in the sake of compatibility (Such as in #108), but I don't want defaults to be different. |
It might be a good idea to leave std.manifestYamlEx as-is, but then add new output format |
I think we've found a workaround for now - we just do
which triggers your codepath here:
|
Oh, it already exists in jsonnet: else if v[len - 1] == '\n' then
local split = std.split(v, '\n');
std.join('\n' + cindent + ' ', ['|'] + split[0:std.length(split) - 1])
else
std.escapeStringJson(v) Even better, then it can be implemented by default for jrsonnet, and then it is possible to update original jsonnet to include this shorthand as well: else if v[len - 1] == '\n' then
local split = std.split(v, '\n');
std.join('\n' + cindent + ' ', ['|'] + split[0:std.length(split) - 1])
else if std.member(v, '\n') then
local split = std.split(v, '\n');
std.join('\n' + cindent + ' ', ['|-'] + split[0:std.length(split) - 1])
else
std.escapeStringJson(v) |
Since 0.9 the string formatting defaults to pretty formatting. See dtolnay/serde-yaml#226.
It would be great to get that updated.
The text was updated successfully, but these errors were encountered: