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.
release-3.5
Vimal K 2019-09-03 19:30:15 +01:00
parent 14624b7d64
commit 4e551d06ed
1 changed files with 12 additions and 13 deletions

View File

@ -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) {