Beispiel #1
0
func (cfg *config) configFromCmdLine() error {
	err := flags.SetFlagsFromEnv("ETCD", cfg.FlagSet)
	if err != nil {
		plog.Fatalf("%v", err)
	}

	cfg.LPUrls = flags.URLsFromFlag(cfg.FlagSet, "listen-peer-urls")
	cfg.APUrls = flags.URLsFromFlag(cfg.FlagSet, "initial-advertise-peer-urls")
	cfg.LCUrls = flags.URLsFromFlag(cfg.FlagSet, "listen-client-urls")
	cfg.ACUrls = flags.URLsFromFlag(cfg.FlagSet, "advertise-client-urls")
	cfg.ClusterState = cfg.clusterState.String()
	cfg.Fallback = cfg.fallback.String()
	cfg.Proxy = cfg.proxy.String()

	// disable default advertise-client-urls if lcurls is set
	missingAC := flags.IsSet(cfg.FlagSet, "listen-client-urls") && !flags.IsSet(cfg.FlagSet, "advertise-client-urls")
	if !cfg.mayBeProxy() && missingAC {
		cfg.ACUrls = nil
	}

	// disable default initial-cluster if discovery is set
	if (cfg.Durl != "" || cfg.DNSCluster != "") && !flags.IsSet(cfg.FlagSet, "initial-cluster") {
		cfg.InitialCluster = ""
	}

	return cfg.validate()
}
Beispiel #2
0
func (cfg *config) configFromCmdLine() error {
	err := flags.SetFlagsFromEnv("ETCD", cfg.FlagSet)
	if err != nil {
		plog.Fatalf("%v", err)
	}

	cfg.lpurls = flags.URLsFromFlag(cfg.FlagSet, "listen-peer-urls")
	cfg.apurls = flags.URLsFromFlag(cfg.FlagSet, "initial-advertise-peer-urls")
	cfg.lcurls = flags.URLsFromFlag(cfg.FlagSet, "listen-client-urls")
	cfg.acurls = flags.URLsFromFlag(cfg.FlagSet, "advertise-client-urls")

	return cfg.validateConfig(func(field string) bool {
		return flags.IsSet(cfg.FlagSet, field)
	})
}