From 4e551d06ed98e645257672488664c1d8e3ea215e Mon Sep 17 00:00:00 2001 From: Vimal K Date: Tue, 3 Sep 2019 19:30:15 +0100 Subject: [PATCH] tools/etcd-dump-logs: Fixed default values for -entry-type flag The tool takes default values but it was not visible which default values were taken. Added default values in proper place, and added a newline at the end of output. --- tools/etcd-dump-logs/main.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tools/etcd-dump-logs/main.go b/tools/etcd-dump-logs/main.go index b0dfd47c5..8161c8909 100644 --- a/tools/etcd-dump-logs/main.go +++ b/tools/etcd-dump-logs/main.go @@ -38,16 +38,21 @@ import ( "go.uber.org/zap" ) +const ( + defaultEntryTypes string = "Normal,ConfigChange" +) + func main() { snapfile := flag.String("start-snap", "", "The base name of snapshot file to start dumping") index := flag.Uint64("start-index", 0, "The index to start dumping") - entrytype := flag.String("entry-type", "", `If set, filters output by entry type. Must be one or more than one of: - ConfigChange, Normal, Request, InternalRaftRequest, - IRRRange, IRRPut, IRRDeleteRange, IRRTxn, - IRRCompaction, IRRLeaseGrant, IRRLeaseRevoke, IRRLeaseCheckpoint`) + // Default entry types are Normal and ConfigChange + entrytype := flag.String("entry-type", defaultEntryTypes, `If set, filters output by entry type. Must be one or more than one of: +ConfigChange, Normal, Request, InternalRaftRequest, +IRRRange, IRRPut, IRRDeleteRange, IRRTxn, +IRRCompaction, IRRLeaseGrant, IRRLeaseRevoke, IRRLeaseCheckpoint`) streamdecoder := flag.String("stream-decoder", "", `The name of an executable decoding tool, the executable must process - hex encoded lines of binary input (from etcd-dump-logs) - and output a hex encoded line of binary for each input line`) +hex encoded lines of binary input (from etcd-dump-logs) +and output a hex encoded line of binary for each input line`) flag.Parse() @@ -279,12 +284,6 @@ func evaluateEntrytypeFlag(entrytype string) []EntryFilter { "IRRLeaseCheckpoint": {passIRRLeaseCheckpoint}, } filters := make([]EntryFilter, 0) - if len(entrytypelist) == 0 { - filters = append(filters, passInternalRaftRequest) - filters = append(filters, passRequest) - filters = append(filters, passUnknownNormal) - filters = append(filters, passConfChange) - } for _, et := range entrytypelist { if f, ok := validRequest[et]; ok { filters = append(filters, f...) @@ -373,7 +372,7 @@ func listEntriesType(entrytype string, streamdecoder string, ents []raftpb.Entry } } - fmt.Printf("\nEntry types (%s) count is : %d", entrytype, cnt) + fmt.Printf("\nEntry types (%s) count is : %d\n", entrytype, cnt) } func parseDecoderOutput(decoderoutput string) (string, string) {