func initializeEtcdStoreClient(logger lager.Logger, etcdOptions *etcddb.ETCDOptions) etcddb.StoreClient { var etcdClient *etcdclient.Client var tr *http.Transport if etcdOptions.IsSSL { if etcdOptions.CertFile == "" || etcdOptions.KeyFile == "" { logger.Fatal("failed-to-construct-etcd-tls-client", errors.New("Require both cert and key path")) } var err error etcdClient, err = etcdclient.NewTLSClient(etcdOptions.ClusterUrls, etcdOptions.CertFile, etcdOptions.KeyFile, etcdOptions.CAFile) if err != nil { logger.Fatal("failed-to-construct-etcd-tls-client", err) } tlsCert, err := tls.LoadX509KeyPair(etcdOptions.CertFile, etcdOptions.KeyFile) if err != nil { logger.Fatal("failed-to-construct-etcd-tls-client", err) } tlsConfig := &tls.Config{ Certificates: []tls.Certificate{tlsCert}, InsecureSkipVerify: true, ClientSessionCache: tls.NewLRUClientSessionCache(etcdOptions.ClientSessionCacheSize), } tr = &http.Transport{ TLSClientConfig: tlsConfig, Dial: etcdClient.DefaultDial, MaxIdleConnsPerHost: etcdOptions.MaxIdleConnsPerHost, } etcdClient.SetTransport(tr) etcdClient.AddRootCA(etcdOptions.CAFile) } else { etcdClient = etcdclient.NewClient(etcdOptions.ClusterUrls) } etcdClient.SetConsistency(etcdclient.STRONG_CONSISTENCY) return etcddb.NewStoreClient(etcdClient) }