provider/coredns.go
func getETCDConfig() (*etcdcv3.Config, error) {
	etcdURLsStr := os.Getenv("ETCD_URLS")
	if etcdURLsStr == "" {
		etcdURLsStr = "http://localhost:2379"
	}
	etcdURLs := strings.Split(etcdURLsStr, ",")
	firstURL := strings.ToLower(etcdURLs[0])
	if strings.HasPrefix(firstURL, "http://") {
		return &etcdcv3.Config{Endpoints: etcdURLs}, nil
	} else if strings.HasPrefix(firstURL, "https://") {
		caFile := os.Getenv("ETCD_CA_FILE")
		certFile := os.Getenv("ETCD_CERT_FILE")
		keyFile := os.Getenv("ETCD_KEY_FILE")
		serverName := os.Getenv("ETCD_TLS_SERVER_NAME")
		isInsecureStr := strings.ToLower(os.Getenv("ETCD_TLS_INSECURE"))
		isInsecure := isInsecureStr == "true" || isInsecureStr == "yes" || isInsecureStr == "1"
		tlsConfig, err := newTLSConfig(certFile, keyFile, caFile, serverName, isInsecure)
		if err != nil {
			return nil, err
		}
		return &etcdcv3.Config{
			Endpoints: etcdURLs,
			TLS:       tlsConfig,
		}, nil
	} else {
		return nil, errors.New("etcd URLs must start with either http:// or https://")
	}
}
func getETCDConfig() (*etcdcv3.Config, error) {
	etcdURLsStr := os.Getenv("ETCD_URLS")
	if etcdURLsStr == "" {
		etcdURLsStr = "http://localhost:2379"
	}
	etcdURLs := strings.Split(etcdURLsStr, ",")
	firstURL := strings.ToLower(etcdURLs[0])
	if strings.HasPrefix(firstURL, "http://") {
		return &etcdcv3.Config{Endpoints: etcdURLs}, nil
	} else if strings.HasPrefix(firstURL, "https://") {
		caFile := os.Getenv("ETCD_CA_FILE")
		certFile := os.Getenv("ETCD_CERT_FILE")
		keyFile := os.Getenv("ETCD_KEY_FILE")
		serverName := os.Getenv("ETCD_TLS_SERVER_NAME")
		isInsecureStr := strings.ToLower(os.Getenv("ETCD_TLS_INSECURE"))
		isInsecure := isInsecureStr == "true" || isInsecureStr == "yes" || isInsecureStr == "1"
		tlsConfig, err := newTLSConfig(certFile, keyFile, caFile, serverName, isInsecure)
		if err != nil {
			return nil, err
		}
		return &etcdcv3.Config{
			Endpoints: etcdURLs,
			TLS:       tlsConfig,
		}, nil
	} else {
		return nil, errors.New("etcd URLs must start with either http:// or https://")
	}
}
func getETCDConfig ( ) ( * etcdcv3 . Config , error ) { etcdURLsStr := os . Getenv ( " " ) if etcdURLsStr == " " { etcdURLsStr = " " } etcdURLs := strings . Split ( etcdURLsStr , " " ) firstURL := strings . ToLower ( etcdURLs [ 0 ] ) if strings . HasPrefix ( firstURL , " " ) { return & etcdcv3 . Config { Endpoints : etcdURLs } , nil } else if strings . HasPrefix ( firstURL , " " ) { caFile := os . Getenv ( " " ) certFile := os . Getenv ( " " ) keyFile := os . Getenv ( " " ) serverName := os . Getenv ( " " ) isInsecureStr := strings . ToLower ( os . Getenv ( " " ) ) isInsecure := isInsecureStr == " " || isInsecureStr == " " || isInsecureStr == " " tlsConfig , err := newTLSConfig ( certFile , keyFile , caFile , serverName , isInsecure ) if err != nil { return nil , err } return & etcdcv3 . Config { Endpoints : etcdURLs , TLS : tlsConfig , } , nil } else { return nil , errors . New ( " " ) } }
// builds etcd client config depending on connection scheme and TLS parameters
builds etcd client config depending on connection scheme and TLS parameters