Browse Source

main: fail on peers/peers-file flags

Jonathan Boulle 11 years ago
parent
commit
ec7bcbb50d
2 changed files with 28 additions and 8 deletions
  1. 7 4
      main.go
  2. 21 4
      pkg/flag.go

+ 7 - 4
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 {
-		flag.Var(&pkg.DeprecatedFlag{f}, f, "")
+	for _, f := range ignored {
+		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 {

+ 21 - 4
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 {
-	log.Printf("WARNING: flag \"-%s\" is no longer supported.", df.Name)
+func (f *IgnoredFlag) Set(s string) error {
+	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 ""
 }
 }