-
Notifications
You must be signed in to change notification settings - Fork 248
Description
It would be nice if std.manifestJson() can produce output with a trailing newline, for two reasons:
Firstly, the purpose of std.manifestJson() is to generate proper JSON content, likely to be written to a file with jsonnet --string later. Terminating the output with newline will allow us to generate JSON content that plays better with POSIX platforms and tools.
Secondly, calculating the MD5 of its output will yield the same result as MD5 of the output file.
Currently, the output of std.manifestJson() has no trailing newline:
jsonnet -e 'std.md5(std.manifestJson({x: 42}))'
(MD5: 144ff3def7c36030bc728b43f717e52a)
But if we output the same result to a file with jsonnet --string and then take the MD5, it has a trailing newline:
jsonnet -e 'std.manifestJson({x: 42})' -S | md5sum
(MD5: 906ecf5568f146cf96d311e351b6ee49)
That yields different results from seemingly identical content.
While we can add trailing newline character manually before taking MD5:
jsonnet -e 'std.md5(std.manifestJson({x: 42})+std.char(10))'
(MD5: 906ecf5568f146cf96d311e351b6ee49)
It is less intuitive and less convenient.
It would be nicer if std.manifestJson() adds the trailing newline for us. Same for INI, YAML, etc.