mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
main: fail on peers/peers-file flags
This commit is contained in:
parent
9e3d045b2b
commit
ec7bcbb50d
11
main.go
11
main.go
@ -38,7 +38,7 @@ var (
|
|||||||
clientTLSInfo = transport.TLSInfo{}
|
clientTLSInfo = transport.TLSInfo{}
|
||||||
peerTLSInfo = transport.TLSInfo{}
|
peerTLSInfo = transport.TLSInfo{}
|
||||||
|
|
||||||
deprecated = []string{
|
ignored = []string{
|
||||||
"cluster-active-size",
|
"cluster-active-size",
|
||||||
"cluster-remove-delay",
|
"cluster-remove-delay",
|
||||||
"cluster-sync-interval",
|
"cluster-sync-interval",
|
||||||
@ -83,13 +83,16 @@ func init() {
|
|||||||
flag.Var(&flagtypes.IPAddressPort{}, "peer-addr", "DEPRECATED: Use -advertise-peer-urls instead.")
|
flag.Var(&flagtypes.IPAddressPort{}, "peer-addr", "DEPRECATED: Use -advertise-peer-urls instead.")
|
||||||
flag.Var(&flagtypes.IPAddressPort{}, "peer-bind-addr", "DEPRECATED: Use -listen-peer-urls instead.")
|
flag.Var(&flagtypes.IPAddressPort{}, "peer-bind-addr", "DEPRECATED: Use -listen-peer-urls instead.")
|
||||||
|
|
||||||
for _, f := range deprecated {
|
for _, f := range ignored {
|
||||||
flag.Var(&pkg.DeprecatedFlag{f}, f, "")
|
flag.Var(&pkg.IgnoredFlag{f}, f, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flag.Var(&pkg.DeprecatedFlag{"peers"}, "peers", "DEPRECATED: Use -bootstrap-config instead")
|
||||||
|
flag.Var(&pkg.DeprecatedFlag{"peers-file"}, "peers-file", "DEPRECATED: Use -bootstrap-config instead")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Usage = pkg.UsageWithIgnoredFlagsFunc(flag.CommandLine, deprecated)
|
flag.Usage = pkg.UsageWithIgnoredFlagsFunc(flag.CommandLine, ignored)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *printVersion {
|
if *printVersion {
|
||||||
|
25
pkg/flag.go
25
pkg/flag.go
@ -12,21 +12,38 @@ import (
|
|||||||
"github.com/coreos/etcd/pkg/transport"
|
"github.com/coreos/etcd/pkg/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DeprecatedFlag encapsulates a flag that may have been previously valid but
|
||||||
|
// is now deprecated. If a DeprecatedFlag is set, an error occurs.
|
||||||
type DeprecatedFlag struct {
|
type DeprecatedFlag struct {
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *DeprecatedFlag) Set(_ string) error {
|
||||||
|
return fmt.Errorf(`flag "-%s" is no longer supported.`, f.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *DeprecatedFlag) String() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// IgnoredFlag encapsulates a flag that may have been previously valid but is
|
||||||
|
// now ignored. If an IgnoredFlag is set, a warning is printed and
|
||||||
|
// operation continues.
|
||||||
|
type IgnoredFlag struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
// IsBoolFlag is defined to allow the flag to be defined without an argument
|
// IsBoolFlag is defined to allow the flag to be defined without an argument
|
||||||
func (df *DeprecatedFlag) IsBoolFlag() bool {
|
func (f *IgnoredFlag) IsBoolFlag() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (df *DeprecatedFlag) Set(s string) error {
|
func (f *IgnoredFlag) Set(s string) error {
|
||||||
log.Printf("WARNING: flag \"-%s\" is no longer supported.", df.Name)
|
log.Printf(`WARNING: flag "-%s" is no longer supported - ignoring.`, f.Name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (df *DeprecatedFlag) String() string {
|
func (f *IgnoredFlag) String() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user