swarmkit icon indicating copy to clipboard operation
swarmkit copied to clipboard

swarm-rafttool: add json output format flag

Open trapier opened this issue 5 years ago • 2 comments

- What I did

Add --format output flag to dump-{object,snapshot,wal} which defaults to "text" (current style) and also accepts "json".

Hopefully this will greatly facilitate future analysis of raft dumps, which are currently only available as walls of pretty printed protobuf.

- How I did it Added cobra flag with validation and introduced switch statements to dump path.

- How to test it

  • Run dump-{object,snapshot,wal} with --format nope. Confirm this errors and prints help.
  • Run dump-{object,snapshot,wal} without the --format flag, or with --format text. Confirm the output is unchanged from present.
  • Run dump-{object,snapshot,wal} with --format json. Pipe the output to jq or other json parser and confirm there are no parsing errors. Confirm information previously presented (e.g. event index from WAL) is still communicated via the json format.

- Description for the changelog N/A

trapier avatar Sep 23 '19 21:09 trapier

Codecov Report

Merging #2898 into master will decrease coverage by 0.38%. The diff coverage is 3.61%.

@@            Coverage Diff             @@
##           master    #2898      +/-   ##
==========================================
- Coverage    61.7%   61.32%   -0.39%     
==========================================
  Files         139      139              
  Lines       22615    22677      +62     
==========================================
- Hits        13955    13906      -49     
- Misses       7188     7304     +116     
+ Partials     1472     1467       -5

codecov[bot] avatar Sep 23 '19 21:09 codecov[bot]

now with pretty-printed json.

trapier avatar Sep 24 '19 20:09 trapier