Blame SOURCES/0001-hack-etcdmain-to-generate-etcd.1.patch

62780e
diff -up etcd-3.4.13/etcdmain/config.go.orig etcd-3.4.13/etcdmain/config.go
62780e
--- etcd-3.4.13/etcdmain/config.go.orig	2020-08-24 21:11:28.000000000 +0200
62780e
+++ etcd-3.4.13/etcdmain/config.go	2020-09-04 00:12:28.424764763 +0200
62780e
@@ -123,14 +123,15 @@ func newConfig() *config {
62780e
 		),
62780e
 	}
62780e
 
62780e
-	fs := cfg.cf.flagSet
62780e
-	fs.Usage = func() {
62780e
+	fs := InitFlagSet(cfg.cf.flagSet)
62780e
+	cfg.cf.flagSet.Usage = func() {
62780e
 		fmt.Fprintln(os.Stderr, usageline)
62780e
 	}
62780e
 
62780e
 	fs.StringVar(&cfg.configFile, "config-file", "", "Path to the server configuration file. Note that if a configuration file is provided, other command line flags and environment variables will be ignored.")
62780e
 
62780e
 	// member
62780e
+	fs.AddGroup("member")
62780e
 	fs.StringVar(&cfg.ec.Dir, "data-dir", cfg.ec.Dir, "Path to the data directory.")
62780e
 	fs.StringVar(&cfg.ec.WalDir, "wal-dir", cfg.ec.WalDir, "Path to the dedicated wal directory.")
62780e
 	fs.Var(
62780e
@@ -163,7 +164,7 @@ func newConfig() *config {
62780e
 	fs.DurationVar(&cfg.ec.GRPCKeepAliveInterval, "grpc-keepalive-interval", cfg.ec.GRPCKeepAliveInterval, "Frequency duration of server-to-client ping to check if a connection is alive (0 to disable).")
62780e
 	fs.DurationVar(&cfg.ec.GRPCKeepAliveTimeout, "grpc-keepalive-timeout", cfg.ec.GRPCKeepAliveTimeout, "Additional duration of wait before closing a non-responsive connection (0 to disable).")
62780e
 
62780e
-	// clustering
62780e
+	fs.AddGroup("clustering")
62780e
 	fs.Var(
62780e
 		flags.NewUniqueURLsWithExceptions(embed.DefaultInitialAdvertisePeerURLs, ""),
62780e
 		"initial-advertise-peer-urls",
62780e
@@ -188,7 +189,7 @@ func newConfig() *config {
62780e
 	fs.BoolVar(&cfg.ec.EnableV2, "enable-v2", cfg.ec.EnableV2, "Accept etcd V2 client requests.")
62780e
 	fs.BoolVar(&cfg.ec.PreVote, "pre-vote", cfg.ec.PreVote, "Enable to run an additional Raft election phase.")
62780e
 
62780e
-	// proxy
62780e
+	fs.AddGroup("proxy")
62780e
 	fs.Var(cfg.cf.proxy, "proxy", fmt.Sprintf("Valid values include %q", cfg.cf.proxy.Valids()))
62780e
 	fs.UintVar(&cfg.cp.ProxyFailureWaitMs, "proxy-failure-wait", cfg.cp.ProxyFailureWaitMs, "Time (in milliseconds) an endpoint will be held in a failed state.")
62780e
 	fs.UintVar(&cfg.cp.ProxyRefreshIntervalMs, "proxy-refresh-interval", cfg.cp.ProxyRefreshIntervalMs, "Time (in milliseconds) of the endpoints refresh interval.")
62780e
@@ -196,7 +197,7 @@ func newConfig() *config {
62780e
 	fs.UintVar(&cfg.cp.ProxyWriteTimeoutMs, "proxy-write-timeout", cfg.cp.ProxyWriteTimeoutMs, "Time (in milliseconds) for a write to timeout.")
62780e
 	fs.UintVar(&cfg.cp.ProxyReadTimeoutMs, "proxy-read-timeout", cfg.cp.ProxyReadTimeoutMs, "Time (in milliseconds) for a read to timeout.")
62780e
 
62780e
-	// security
62780e
+	fs.AddGroup("security")
62780e
 	fs.StringVar(&cfg.ec.ClientTLSInfo.CertFile, "cert-file", "", "Path to the client server TLS cert file.")
62780e
 	fs.StringVar(&cfg.ec.ClientTLSInfo.KeyFile, "key-file", "", "Path to the client server TLS key file.")
62780e
 	fs.BoolVar(&cfg.ec.ClientTLSInfo.ClientCertAuth, "client-cert-auth", false, "Enable client cert authentication.")
62780e
@@ -222,7 +223,7 @@ func newConfig() *config {
62780e
 	)
62780e
 	fs.Var(flags.NewUniqueStringsValue("*"), "host-whitelist", "Comma-separated acceptable hostnames from HTTP client requests, if server is not secure (empty means allow all).")
62780e
 
62780e
-	// logging
62780e
+	fs.AddGroup("logging")
62780e
 	fs.StringVar(&cfg.ec.Logger, "logger", "capnslog", "Specify 'zap' for structured logging or 'capnslog'. WARN: 'capnslog' is being deprecated in v3.5.")
62780e
 	fs.Var(flags.NewUniqueStringsValue(embed.DefaultLogOutput), "log-output", "[TO BE DEPRECATED IN v3.5] use '--log-outputs'.")
62780e
 	fs.Var(flags.NewUniqueStringsValue(embed.DefaultLogOutput), "log-outputs", "Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd, or list of comma separated output targets.")
62780e
@@ -230,27 +231,27 @@ func newConfig() *config {
62780e
 	fs.StringVar(&cfg.ec.LogLevel, "log-level", logutil.DefaultLogLevel, "Configures log level. Only supports debug, info, warn, error, panic, or fatal. Default 'info'.")
62780e
 	fs.StringVar(&cfg.ec.LogPkgLevels, "log-package-levels", "", "[TO BE DEPRECATED IN v3.5] Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG').")
62780e
 
62780e
-	// version
62780e
+	fs.AddGroup("version")
62780e
 	fs.BoolVar(&cfg.printVersion, "version", false, "Print the version and exit.")
62780e
 
62780e
 	fs.StringVar(&cfg.ec.AutoCompactionRetention, "auto-compaction-retention", "0", "Auto compaction retention for mvcc key value store. 0 means disable auto compaction.")
62780e
 	fs.StringVar(&cfg.ec.AutoCompactionMode, "auto-compaction-mode", "periodic", "interpret 'auto-compaction-retention' one of: periodic|revision. 'periodic' for duration based retention, defaulting to hours if no time unit is provided (e.g. '5m'). 'revision' for revision number based retention.")
62780e
 
62780e
-	// pprof profiler via HTTP
62780e
+	fs.AddGroup("profiling")
62780e
 	fs.BoolVar(&cfg.ec.EnablePprof, "enable-pprof", false, "Enable runtime profiling data via HTTP server. Address is at client URL + \"/debug/pprof/\"")
62780e
 
62780e
 	// additional metrics
62780e
 	fs.StringVar(&cfg.ec.Metrics, "metrics", cfg.ec.Metrics, "Set level of detail for exported metrics, specify 'extensive' to include histogram metrics")
62780e
 
62780e
-	// auth
62780e
+	fs.AddGroup("auth")
62780e
 	fs.StringVar(&cfg.ec.AuthToken, "auth-token", cfg.ec.AuthToken, "Specify auth token specific options.")
62780e
 	fs.UintVar(&cfg.ec.BcryptCost, "bcrypt-cost", cfg.ec.BcryptCost, "Specify bcrypt algorithm cost factor for auth password hashing.")
62780e
 	fs.UintVar(&cfg.ec.AuthTokenTTL, "auth-token-ttl", cfg.ec.AuthTokenTTL, "The lifetime in seconds of the auth token.")
62780e
 
62780e
-	// gateway
62780e
+	fs.AddGroup("gateway")
62780e
 	fs.BoolVar(&cfg.ec.EnableGRPCGateway, "enable-grpc-gateway", true, "Enable GRPC gateway.")
62780e
 
62780e
-	// experimental
62780e
+	fs.AddGroup("experimental")
62780e
 	fs.BoolVar(&cfg.ec.ExperimentalInitialCorruptCheck, "experimental-initial-corrupt-check", cfg.ec.ExperimentalInitialCorruptCheck, "Enable to check data corruption before serving any client/peer traffic.")
62780e
 	fs.DurationVar(&cfg.ec.ExperimentalCorruptCheckTime, "experimental-corrupt-check-time", cfg.ec.ExperimentalCorruptCheckTime, "Duration of time between cluster corruption check passes.")
62780e
 	fs.StringVar(&cfg.ec.ExperimentalEnableV2V3, "experimental-enable-v2v3", cfg.ec.ExperimentalEnableV2V3, "v3 prefix for serving emulated v2 state.")
62780e
@@ -259,9 +260,12 @@ func newConfig() *config {
62780e
 	fs.IntVar(&cfg.ec.ExperimentalCompactionBatchLimit, "experimental-compaction-batch-limit", cfg.ec.ExperimentalCompactionBatchLimit, "Sets the maximum revisions deleted in each compaction batch.")
62780e
 	fs.DurationVar(&cfg.ec.ExperimentalWatchProgressNotifyInterval, "experimental-watch-progress-notify-interval", cfg.ec.ExperimentalWatchProgressNotifyInterval, "Duration of periodic watch progress notifications.")
62780e
 
62780e
-	// unsafe
62780e
+	fs.AddGroup("unsafe")
62780e
 	fs.BoolVar(&cfg.ec.UnsafeNoFsync, "unsafe-no-fsync", false, "Disables fsync, unsafe, will cause data loss.")
62780e
 	fs.BoolVar(&cfg.ec.ForceNewCluster, "force-new-cluster", false, "Force to create a new one member cluster.")
62780e
+ 
62780e
+	fs.GenMan()
62780e
+	os.Exit(0)
62780e
 
62780e
 	// ignored
62780e
 	for _, f := range cfg.ignored {
62780e
diff -up etcd-3.4.13/etcdmain/fake_flagset.go.orig etcd-3.4.13/etcdmain/fake_flagset.go
62780e
--- etcd-3.4.13/etcdmain/fake_flagset.go.orig	2020-09-04 00:10:11.223684457 +0200
62780e
+++ etcd-3.4.13/etcdmain/fake_flagset.go	2020-09-04 00:10:11.223684457 +0200
62780e
@@ -0,0 +1,157 @@
62780e
+package etcdmain
62780e
+
62780e
+import (
62780e
+	"flag"
62780e
+	"fmt"
62780e
+	"strconv"
62780e
+	"strings"
62780e
+	"time"
62780e
+)
62780e
+
62780e
+type flagInfo struct {
62780e
+	value fmt.Stringer
62780e
+	name  string
62780e
+	usage string
62780e
+}
62780e
+
62780e
+type stringValue string
62780e
+
62780e
+func (s *stringValue) String() string { return string(*s) }
62780e
+
62780e
+type uintValue uint
62780e
+
62780e
+func (i *uintValue) String() string { return strconv.FormatUint(uint64(*i), 10) }
62780e
+
62780e
+type uint64Value uint64
62780e
+
62780e
+func (i *uint64Value) String() string { return strconv.FormatUint(uint64(*i), 10) }
62780e
+
62780e
+type int64Value int64
62780e
+
62780e
+func (i *int64Value) String() string { return strconv.FormatInt(int64(*i), 10) }
62780e
+
62780e
+type durationValue time.Duration
62780e
+
62780e
+func (d *durationValue) String() string { return (*time.Duration)(d).String() }
62780e
+
62780e
+type boolValue bool
62780e
+
62780e
+func (b *boolValue) String() string { return strconv.FormatBool(bool(*b)) }
62780e
+
62780e
+type FakeFlagSet struct {
62780e
+	fs        *flag.FlagSet
62780e
+	flags     map[string][]flagInfo
62780e
+	groups    []string
62780e
+	lastGroup string
62780e
+}
62780e
+
62780e
+func InitFlagSet(fs *flag.FlagSet) *FakeFlagSet {
62780e
+	return &FakeFlagSet{
62780e
+		fs:    fs,
62780e
+		flags: make(map[string][]flagInfo),
62780e
+	}
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) AddGroup(name string) {
62780e
+	fs.flags[name] = nil
62780e
+	fs.groups = append(fs.groups, name)
62780e
+	fs.lastGroup = name
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) Var(value flag.Value, name string, usage string) {
62780e
+	fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
62780e
+		value: value,
62780e
+		name:  name,
62780e
+		usage: usage,
62780e
+	})
62780e
+	fs.fs.Var(value, name, usage)
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) StringVar(p *string, name string, value string, usage string) {
62780e
+	fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
62780e
+		value: (*stringValue)(&value),
62780e
+		name:  name,
62780e
+		usage: usage,
62780e
+	})
62780e
+	fs.fs.StringVar(p, name, value, usage)
62780e
+}
62780e
+
62780e
+// -- int Value
62780e
+type intValue int
62780e
+
62780e
+func (i *intValue) String() string { return strconv.Itoa(int(*i)) }
62780e
+
62780e
+func (fs *FakeFlagSet) UintVar(p *uint, name string, value uint, usage string) {
62780e
+	fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
62780e
+		value: (*uintValue)(&value),
62780e
+		name:  name,
62780e
+		usage: usage,
62780e
+	})
62780e
+	fs.fs.UintVar(p, name, value, usage)
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) {
62780e
+	fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
62780e
+		value: (*uint64Value)(&value),
62780e
+		name:  name,
62780e
+		usage: usage,
62780e
+	})
62780e
+	fs.fs.Uint64Var(p, name, value, usage)
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) IntVar(p *int, name string, value int, usage string) {
62780e
+	fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
62780e
+		value: (*intValue)(&value),
62780e
+		name:  name,
62780e
+		usage: usage,
62780e
+	})
62780e
+	fs.fs.IntVar(p, name, value, usage)
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) Int64Var(p *int64, name string, value int64, usage string) {
62780e
+	fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
62780e
+		value: (*int64Value)(&value),
62780e
+		name:  name,
62780e
+		usage: usage,
62780e
+	})
62780e
+	fs.fs.Int64Var(p, name, value, usage)
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
62780e
+	fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
62780e
+		value: (*durationValue)(&value),
62780e
+		name:  name,
62780e
+		usage: usage,
62780e
+	})
62780e
+	fs.fs.DurationVar(p, name, value, usage)
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) BoolVar(p *bool, name string, value bool, usage string) {
62780e
+	fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
62780e
+		value: (*boolValue)(&value),
62780e
+		name:  name,
62780e
+		usage: usage,
62780e
+	})
62780e
+	fs.fs.BoolVar(p, name, value, usage)
62780e
+}
62780e
+
62780e
+func (fs *FakeFlagSet) GenMan() {
62780e
+	fmt.Printf(".TH \"ETCD\" \"1\" \" etcd User Manuals\" \"Etcd contributors\" \"Nov 2017\"  \"\"\n")
62780e
+	fmt.Printf(".SH NAME:\netcd - Distributed reliable key-value store for the most critical data of a distributed system\n\n")
62780e
+	fmt.Printf(".SH USAGE:\netcd [flags]\n\n")
62780e
+	fmt.Printf(".SH DESCRIPTION:\nEtcd is a distributed key-value store designed to reliably and quickly preserve and provide access to critical data. It enables reliable distributed coordination through distributed locking, leader elections, and write barriers. An etcd cluster is intended for high availability and permanent data storage and retrieval.\n\n")
62780e
+	fmt.Printf(".SH GENERAL OPTIONS\n\n")
62780e
+	for _, group := range fs.groups {
62780e
+		fmt.Printf(".I %v flags\n\n", strings.Title(group))
62780e
+		for _, flag := range fs.flags[group] {
62780e
+			var flagstr string
62780e
+			if len(flag.name) == 1 {
62780e
+				flagstr = "-" + flag.name
62780e
+			} else {
62780e
+				flagstr = "--" + flag.name
62780e
+			}
62780e
+			fmt.Printf(".RS\n\\fB%v %v\\fP\n      %v\n\n.RE\n", flagstr, flag.value.String(), flag.usage)
62780e
+		}
62780e
+	}
62780e
+	fmt.Printf(".SH SEE ALSO:\n\\fBetcdctl(1)\\fP, \\fBetcdctl2(1)\\fP, \\fBetcdctl3(1)\\fP\n\n")
62780e
+}