func newETCD3Storage(c storagebackend.Config) (storage.Interface, error) { tlsInfo := transport.TLSInfo{ CertFile: c.CertFile, KeyFile: c.KeyFile, CAFile: c.CAFile, } tlsConfig, err := tlsInfo.ClientConfig() if err != nil { return nil, err } // NOTE: Client relies on nil tlsConfig // for non-secure connections, update the implicit variable if len(c.CertFile) == 0 && len(c.KeyFile) == 0 && len(c.CAFile) == 0 { tlsConfig = nil } cfg := clientv3.Config{ Endpoints: c.ServerList, TLS: tlsConfig, } client, err := clientv3.New(cfg) if err != nil { return nil, err } etcd3.StartCompactor(context.Background(), client) return etcd3.New(client, c.Codec, c.Prefix), nil }
func newETCD3Storage(c storagebackend.Config) (storage.Interface, DestroyFunc, error) { tlsInfo := transport.TLSInfo{ CertFile: c.CertFile, KeyFile: c.KeyFile, CAFile: c.CAFile, } tlsConfig, err := tlsInfo.ClientConfig() if err != nil { return nil, nil, err } // NOTE: Client relies on nil tlsConfig // for non-secure connections, update the implicit variable if len(c.CertFile) == 0 && len(c.KeyFile) == 0 && len(c.CAFile) == 0 { tlsConfig = nil } cfg := clientv3.Config{ Endpoints: c.ServerList, TLS: tlsConfig, } client, err := clientv3.New(cfg) if err != nil { return nil, nil, err } ctx, cancel := context.WithCancel(context.Background()) etcd3.StartCompactor(ctx, client) destroyFunc := func() { cancel() client.Close() } if c.Quorum { return etcd3.New(client, c.Codec, c.Prefix), destroyFunc, nil } return etcd3.NewWithNoQuorumRead(client, c.Codec, c.Prefix), destroyFunc, nil }
func newETCD3Storage(c storagebackend.Config, codec runtime.Codec) (storage.Interface, error) { endpoints := c.ServerList for i, s := range endpoints { endpoints[i] = strings.TrimLeft(s, "http://") } cfg := clientv3.Config{ Endpoints: endpoints, } client, err := clientv3.New(cfg) if err != nil { return nil, err } etcd3.StartCompactor(context.Background(), client) return etcd3.New(client, codec, c.Prefix), nil }
func newETCD3Storage(c storagebackend.Config) (storage.Interface, error) { tlsInfo := transport.TLSInfo{ CertFile: c.CertFile, KeyFile: c.KeyFile, CAFile: c.CAFile, } tlsConfig, err := tlsInfo.ClientConfig() if err != nil { return nil, err } cfg := clientv3.Config{ Endpoints: c.ServerList, TLS: tlsConfig, } client, err := clientv3.New(cfg) if err != nil { return nil, err } etcd3.StartCompactor(context.Background(), client) return etcd3.New(client, c.Codec, c.Prefix), nil }