func GetKV(key string) string {
	ctx, cancel := context.WithTimeout(context.Background(), timeOut)
	defer cancel()
	resp, err := cli.Get(ctx, key, clientv3.WithPrefix())
	if err != nil {
		log.Etcd.Error(err)
		return ""
	}
	if resp.Count == 0 {
		return ""
	}
	return string(resp.Kvs[0].Value)
}
GetKV returns value for the given key
package etcdcli
import (
	"context"
	"fmt"
	"github.com/harmonycloud/bifrost/pkg/log"
	"github.com/harmonycloud/bifrost/pkg/types"
	"go.etcd.io/etcd/clientv3"
	"go.etcd.io/etcd/pkg/transport"
	"strings"
	"time"
)
const (
	clientTimeout    = 10 * time.Second
	keepaliveTime    = 30 * time.Second
	keepaliveTimeout = 10 * time.Second
	timeOut          = 1 * time.Second
)
var cli *clientv3.Client
func Init(config *types.IPAMConfig) (*clientv3.Client, error) {
	etcdLocation := []string{}
	if config.EtcdEndpoints != "" {
		etcdLocation = strings.Split(config.EtcdEndpoints, ",")
	}
	if len(etcdLocation) == 0 {
		log.Etcd.Warnf("No etcd endpoints specified in etcdv3 API config")
		return nil, fmt.Errorf("no etcd endpoints specified")
	}
	cfg := clientv3.Config{
		Endpoints:            etcdLocation,
		DialTimeout:          clientTimeout,
		DialKeepAliveTime:    keepaliveTime,
		DialKeepAliveTimeout: keepaliveTimeout,
	}
	if config.EtcdCaCertFile != "" && config.EtcdKeyFile != "" {
		tlsInfo := &transport.TLSInfo{
			TrustedCAFile: config.EtcdCaCertFile,
			CertFile:      config.EtcdCertFile,
			KeyFile:       config.EtcdKeyFile,
		}
		tls, err := tlsInfo.ClientConfig()
		if err != nil {
			return nil, fmt.Errorf("could not initialize etcdv3 client: %+v", err)
		}
		cfg.TLS = tls
	}
	if config.EtcdUsername != "" && config.EtcdPassword != "" {
		cfg.Username = config.EtcdUsername
		cfg.Password = config.EtcdPassword
	}
	client, err := clientv3.New(cfg)
	cli = client
	if err != nil {
		return nil, err
	}
	return client, nil
}