knife-backup
knife-backup copied to clipboard
Fix pretty JSON generation
see: http://stackoverflow.com/questions/2567670/ruby-json-pretty-generate-is-pretty-unpretty It would be really nice for reading and editing the backups before restoring them.
Which version are you using and which data are you referring to?
I am using version v0.0.11 and i am referring to the minified JSON, for example in the roles backup files.
@DarkGigaByte - thx, by any chance did you look into other files that you backed up? Will look into it.
Yeah, i did. The data bags are fine and pretty formatted. The other categories are all not/unpretty formatted.
@DarkGigaByte Send me an example if can. Mine look fine...
Example of unpretty environment "development" exported on Linux Mint:
{"name":"development","description":"development","cookbook_versions":{"foobar_cookbook":"= 0.1.0"},"json_class":"Chef::Environment","chef_type":"environment","default_attributes":{},"override_attributes":{}}
How it should look pretty formatted: http://pastebin.com/Ju7m7FUt
it was prettified in 0.0.8, but something changed between 0.0.8-0.0.10
please add prettifying back, as i'm commiting the backup versions to git, it would be easier to see changes if prettified.
EDIT: i think the real change was with underlying ruby upgrade 1.9 -> 2.4
i don't get it. if i read and invoke JSON.pretty_generate
, it works fine:
file_name = 'nodes/example.json'
data = File.read(file_name)
some_data = JSON.parse(data)
encoded = JSON.pretty_generate(some_data)
yourfile = '/tmp/out.json'
File.open(yourfile, 'w') { |file| file.write(encoded) }
and the code uses same method: https://github.com/mdxp/knife-backup/blob/v0.0.12/lib/chef/knife/backup_export.rb#L127
i'm even more puzzled, i updated 0.0.10 to 0.0.12 and the output is prettified.
versions (mostly note to myself):
$ rpm -q ruby knife-backup ruby-json
ruby-2.4.4-12.x86_64
knife-backup-0.0.12-1.noarch
ruby-json-2.0.4-2.4.4.12.x86_64
so, imho it can be closed. as output is prettified