mirror of https://github.com/kubernetes/kops.git
Add new SLB() for ALICloud with official SDK
This commit is contained in:
parent
98c35cd220
commit
074af1c962
|
|
@ -24,6 +24,9 @@ import (
|
||||||
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
|
alicloud "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
|
||||||
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
|
||||||
|
slbnew "github.com/aliyun/alibaba-cloud-sdk-go/services/slb"
|
||||||
"github.com/denverdino/aliyungo/common"
|
"github.com/denverdino/aliyungo/common"
|
||||||
"github.com/denverdino/aliyungo/ecs"
|
"github.com/denverdino/aliyungo/ecs"
|
||||||
"github.com/denverdino/aliyungo/ess"
|
"github.com/denverdino/aliyungo/ess"
|
||||||
|
|
@ -50,6 +53,12 @@ var KubernetesKopsIdentity = fmt.Sprintf("Kubernetes.Kops/%s", prj.Version)
|
||||||
type ALICloud interface {
|
type ALICloud interface {
|
||||||
fi.Cloud
|
fi.Cloud
|
||||||
|
|
||||||
|
// Clients that use official Alicloud go sdk
|
||||||
|
SLB() *slbnew.Client
|
||||||
|
|
||||||
|
// Since package github.com/denverdino/aliyungo is not actively maintained,
|
||||||
|
// clients that use github.com/denverdino/aliyungo, will be deprecated after
|
||||||
|
// the above official SDK clients covers all of them
|
||||||
EcsClient() *ecs.Client
|
EcsClient() *ecs.Client
|
||||||
SlbClient() *slb.Client
|
SlbClient() *slb.Client
|
||||||
RamClient() *ram.RamClient
|
RamClient() *ram.RamClient
|
||||||
|
|
@ -66,6 +75,8 @@ type ALICloud interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type aliCloudImplementation struct {
|
type aliCloudImplementation struct {
|
||||||
|
slb *slbnew.Client
|
||||||
|
|
||||||
ecsClient *ecs.Client
|
ecsClient *ecs.Client
|
||||||
slbClient *slb.Client
|
slbClient *slb.Client
|
||||||
ramClient *ram.RamClient
|
ramClient *ram.RamClient
|
||||||
|
|
@ -100,12 +111,27 @@ func NewALICloud(region string, tags map[string]string) (ALICloud, error) {
|
||||||
c.ramClient = ramclient.(*ram.RamClient)
|
c.ramClient = ramclient.(*ram.RamClient)
|
||||||
c.essClient = ess.NewClient(accessKeyID, accessKeySecret)
|
c.essClient = ess.NewClient(accessKeyID, accessKeySecret)
|
||||||
c.vpcClient = ecs.NewVPCClient(accessKeyID, accessKeySecret, common.Region(region))
|
c.vpcClient = ecs.NewVPCClient(accessKeyID, accessKeySecret, common.Region(region))
|
||||||
|
|
||||||
c.tags = tags
|
c.tags = tags
|
||||||
|
|
||||||
|
// With Alicloud official go SDK
|
||||||
|
var err error
|
||||||
|
|
||||||
|
config := alicloud.NewConfig()
|
||||||
|
credential := credentials.NewAccessKeyCredential(accessKeyID, accessKeySecret)
|
||||||
|
|
||||||
|
c.slb, err = slbnew.NewClientWithOptions(region, config, credential)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error creating slb sdk client: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *aliCloudImplementation) SLB() *slbnew.Client {
|
||||||
|
return c.slb
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clients as below are with github.com/denverdino/aliyungo
|
||||||
func (c *aliCloudImplementation) EcsClient() *ecs.Client {
|
func (c *aliCloudImplementation) EcsClient() *ecs.Client {
|
||||||
return c.ecsClient
|
return c.ecsClient
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue