myENA / consul-backinator

Command line Consul backup and restore utility supporting KVs, ACLs and Queries
Mozilla Public License 2.0
226 stars 22 forks source link

Dump readable values to stdout #1

Closed matschaffer closed 8 years ago

matschaffer commented 8 years ago

I noticed that the -dump option provides values as base64 encoded.

Would be possible/preferable to display them as straight strings in the dump output?

aaronhurt commented 8 years ago

The -dump option simply returns the raw decrypted/decompressed output from the Consul API. It is just an easy way to "view" your backup files.

-- Aaron

On Mar 6, 2016, at 10:10 PM, Mat Schaffer notifications@github.com wrote:

I noticed that the -dump option provides values as base64 encoded.

Would be possible/preferable to display them as straight strings in the dump output?

— Reply to this email directly or view it on GitHub.

matschaffer commented 8 years ago

For sure. My thinking was that if we had multiple backup files it could be useful to see the full set of keys & values to confirm we're reloading the best possible backup. For the time being I came up with this:

> consul-backinator -restore -dump |\
  jq -r '.[] | [.Key, .Value] | @sh' |\
  xargs -I{} -n1 sh -c 'echo $(echo {} | cut -d" " -f1)=$(echo {} | cut -d" " -f2 | base64 -d)'

But it's pretty roundabout compared with what I'm guessing it'd take to have the dump code show decoded values.

Maybe -dump -decode would be better?

aaronhurt commented 8 years ago

Got it. So instead of just decoding would you actually prefer a "human readable" output? Maybe something in ascii table format?

Something like this ... https://github.com/olekukonko/tablewriter

matschaffer commented 8 years ago

That sounds like a cool idea. I haven't put much time into brainstorming formats but so long as it's diffable it should be good.

On Tuesday, 8 March 2016, Aaron Hurt notifications@github.com wrote:

Got it. So instead of just decoding would you actually prefer a "human readable" output? Maybe something in ascii table format?

— Reply to this email directly or view it on GitHub https://github.com/myENA/consul-backinator/issues/1#issuecomment-193330158 .

-Mat

matschaffer.com

aaronhurt commented 8 years ago

I couldn't think of a nice way to use a table or other format with all the possible options for a data payload in a KV store. I settled on just a very simple output format ...

Key: keyName
ValueHere and Here
and Here
Key: someOtherKey
more Values and Stuff

This should be greppable/diffable and give you approximately what you wanted.

matschaffer commented 8 years ago

Looks fantastic. Thanks!