libcalico-go接口调用

 test.go:

package test

import (
	"context"
	"hfftest/conf"

	"github.com/projectcalico/libcalico-go/lib/apiconfig"
	"github.com/projectcalico/libcalico-go/lib/clientv3"
	"github.com/projectcalico/libcalico-go/lib/options"
	"github.com/sirupsen/logrus"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var ClientV3 clientv3.Interface

func CalicoSetup() {
	var err error
	ClientV3, err = clientv3.New(apiconfig.CalicoAPIConfig{
		TypeMeta:   metav1.TypeMeta{},
		ObjectMeta: metav1.ObjectMeta{},
		Spec: apiconfig.CalicoAPIConfigSpec{
			DatastoreType: apiconfig.EtcdV3,
			EtcdConfig: apiconfig.EtcdConfig{
				EtcdEndpoints:  conf.EtcdEndpoints,
				EtcdKeyFile:    conf.EtcdKeyFile,
				EtcdCertFile:   conf.EtcdCertFile,
				EtcdCACertFile: conf.EtcdCACertFile,
			}},
	})

	if err != nil {
		logrus.Error(err.Error())
		return
	}

	logrus.Info("setup calico client succeed")
}

func Test() {
	logrus.Println("my test...")
	CalicoSetup()
	ctx := context.Background()
	ipPools, err := ClientV3.IPPools().List(ctx, options.ListOptions{})
	if err != nil {
		logrus.Errorln(err)
	}
	logrus.Infoln(ipPools)

}

 conf.go

package conf

var (
	EtcdEndpoints  = "10.10.0.13:2379"
	EtcdKeyFile    = "./etcd-key.pem"
	EtcdCertFile   = "./etcd.pem"
	EtcdCACertFile = "./ca.pem"
)

go.mod:

module hfftest

go 1.17

require (
	github.com/projectcalico/libcalico-go v1.7.2-0.20200303001954-8d098ee0dd61
	github.com/sirupsen/logrus v1.4.2
	github.com/spf13/cobra v1.2.1
	k8s.io/apimachinery v0.0.0-20191028221656-72ed19daf4bb
)

require (
	cloud.google.com/go v0.81.0 // indirect
	github.com/Azure/go-autorest/autorest v0.9.0 // indirect
	github.com/Azure/go-autorest/autorest/adal v0.5.0 // indirect
	github.com/Azure/go-autorest/autorest/date v0.1.0 // indirect
	github.com/Azure/go-autorest/logger v0.1.0 // indirect
	github.com/Azure/go-autorest/tracing v0.5.0 // indirect
	github.com/coreos/etcd v3.3.18+incompatible // indirect
	github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
	github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
	github.com/go-playground/locales v0.12.1 // indirect
	github.com/go-playground/universal-translator v0.0.0-20170327191703-71201497bace // indirect
	github.com/gogo/protobuf v1.3.2 // indirect
	github.com/golang/protobuf v1.5.2 // indirect
	github.com/google/go-cmp v0.5.5 // indirect
	github.com/google/gofuzz v1.0.0 // indirect
	github.com/google/uuid v1.1.1 // indirect
	github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d // indirect
	github.com/gophercloud/gophercloud v0.1.0 // indirect
	github.com/hashicorp/golang-lru v0.5.1 // indirect
	github.com/imdario/mergo v0.3.5 // indirect
	github.com/inconshreveable/mousetrap v1.0.0 // indirect
	github.com/json-iterator/go v1.1.11 // indirect
	github.com/kelseyhightower/envconfig v0.0.0-20180517194557-dd1402a4d99d // indirect
	github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
	github.com/leodido/go-urn v0.0.0-20181204092800-a67a23e1c1af // indirect
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
	github.com/modern-go/reflect2 v1.0.1 // indirect
	github.com/projectcalico/go-json v0.0.0-20161128004156-6219dc7339ba // indirect
	github.com/projectcalico/go-yaml-wrapper v0.0.0-20191112210931-090425220c54 // indirect
	github.com/satori/go.uuid v1.2.0 // indirect
	github.com/spf13/pflag v1.0.5 // indirect
	go.uber.org/atomic v1.7.0 // indirect
	go.uber.org/multierr v1.6.0 // indirect
	go.uber.org/zap v1.17.0 // indirect
	golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
	golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
	golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect
	golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
	golang.org/x/text v0.3.5 // indirect
	golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
	google.golang.org/appengine v1.6.7 // indirect
	google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
	google.golang.org/grpc v1.38.0 // indirect
	google.golang.org/protobuf v1.26.0 // indirect
	gopkg.in/go-playground/validator.v9 v9.27.0 // indirect
	gopkg.in/inf.v0 v0.9.1 // indirect
	gopkg.in/yaml.v2 v2.4.0 // indirect
	k8s.io/api v0.0.0-20191114100352-16d7abae0d2a // indirect
	k8s.io/client-go v0.0.0-20191114101535-6c5935290e33 // indirect
	k8s.io/klog v0.4.0 // indirect
	k8s.io/utils v0.0.0-20191114200735-6ca3b61696b6 // indirect
	sigs.k8s.io/yaml v1.1.0 // indirect

)

replace google.golang.org/grpc => google.golang.org/grpc v1.25.1

注意grpc版本匹配问题

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]中的代码展示了一个使用element-ui的el-radio-group组件的示例。在这个示例中,v-model绑定了一个名为sortType的变量,用于控制选中的单选按钮。当选中的值发生变化时,会触发handleSortTypeChange方法,该方法会根据选中的值重新获取排序后的数据。 引用\[2\]和引用\[3\]中的代码展示了两种不同的方法来处理el-radio-group的值变化事件。在引用\[2\]中,使用了@change.native来监听值的变化,并分别调用了test1、test2和test3方法来处理不同的选项。而在引用\[3\]中,使用了@click.native来监听点击事件,并通过传递参数的方式将选项的值传递给对应的方法。 根据你的问题,如果你想在接口调用后再改变el-radio-group的值,你可以在接口调用成功后,通过修改sortType的值来改变选中的单选按钮。例如,在接口调用成功后,你可以将sortType的值设置为需要的值,然后调用handleSortTypeChange方法来重新获取排序后的数据。 总结起来,你可以通过修改sortType的值来改变el-radio-group的选中值,并在值变化后调用相应的方法来处理逻辑。 #### 引用[.reference_title] - *1* [elementui el-radio-group 分组排序问题](https://blog.csdn.net/xia_zixin/article/details/115182726)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [element el-radio-group 点击触发两次方法的解决方法](https://blog.csdn.net/qq_41793354/article/details/119959009)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值