diff --git a/main.go b/main.go index 1303d038b..94821c282 100644 --- a/main.go +++ b/main.go @@ -77,7 +77,10 @@ var ( func init() { fs.Var(clusterState, "initial-cluster-state", "Initial cluster configuration for bootstrapping") - clusterState.Set(etcdserver.ClusterStateValueNew) + if err := clusterState.Set(etcdserver.ClusterStateValueNew); err != nil { + // Should never happen. + log.Panicf("unexpected error setting up clusterState: %v", err) + } fs.Var(flags.NewURLsValue("http://localhost:2380,http://localhost:7001"), "initial-advertise-peer-urls", "List of this member's peer URLs to advertise to the rest of the cluster") fs.Var(flags.NewURLsValue("http://localhost:2379,http://localhost:4001"), "advertise-client-urls", "List of this member's client URLs to advertise to the rest of the cluster") @@ -87,7 +90,10 @@ func init() { fs.Var(corsInfo, "cors", "Comma-separated white list of origins for CORS (cross-origin resource sharing).") fs.Var(proxyFlag, "proxy", fmt.Sprintf("Valid values include %s", strings.Join(flags.ProxyValues, ", "))) - proxyFlag.Set(flags.ProxyValueOff) + if err := proxyFlag.Set(flags.ProxyValueOff); err != nil { + // Should never happen. + log.Panicf("unexpected error setting up proxyFlag: %v", err) + } fs.StringVar(&clientTLSInfo.CAFile, "ca-file", "", "Path to the client server TLS CA file.") fs.StringVar(&clientTLSInfo.CertFile, "cert-file", "", "Path to the client server TLS cert file.") diff --git a/pkg/flags/flag.go b/pkg/flags/flag.go index a3cf3597d..5090add83 100644 --- a/pkg/flags/flag.go +++ b/pkg/flags/flag.go @@ -95,7 +95,10 @@ func SetFlagsFromEnv(fs *flag.FlagSet) { key := "ETCD_" + strings.ToUpper(strings.Replace(f.Name, "-", "_", -1)) val := os.Getenv(key) if val != "" { - fs.Set(f.Name, val) + if err := fs.Set(f.Name, val); err != nil { + // Should never happen + log.Panicf("error setting flag from env: %v", err) + } } } }) diff --git a/pkg/flags/urls.go b/pkg/flags/urls.go index 8124b9ffc..2777a807a 100644 --- a/pkg/flags/urls.go +++ b/pkg/flags/urls.go @@ -17,6 +17,7 @@ package flags import ( + "log" "strings" "github.com/coreos/etcd/pkg/types" @@ -47,6 +48,8 @@ func (us *URLsValue) String() string { func NewURLsValue(init string) *URLsValue { v := &URLsValue{} - v.Set(init) + if err := v.Set(init); err != nil { + log.Panicf("error setting URLsValue: %v", err) + } return v }