swarmkit
swarmkit copied to clipboard
swarm-rafttool: add json output format flag
- 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 tojq
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
Codecov Report
Merging #2898 into master will decrease coverage by
0.38%
. The diff coverage is3.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
now with pretty-printed json.