Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

华为云集群导入功能 #3025

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7304,7 +7304,7 @@
"title": "diskPartition"
}
},
"title": "CloudDataDisk 云磁盘格式化数据, 对应CVM数据盘。应用于节点模版\n主要用于 CA 自动扩容节点并上架节点时重装系统,多块数据盘 mountTarget 不能重复\n上架已存在节点时, 用户需指定diskPartition参数区分设备"
"title": "CloudDataDisk 云磁盘格式化数据, 对应CVM数据盘。应用于节点模版\r\n主要用于 CA 自动扩容节点并上架节点时重装系统,多块数据盘 mountTarget 不能重复\r\n上架已存在节点时, 用户需指定diskPartition参数区分设备"
},
"clustermanagerCloudModuleFlag": {
"type": "object",
Expand Down Expand Up @@ -18537,7 +18537,7 @@
}
}
},
"title": "https://github.com/golang/protobuf/issues/1118\nhttps://pkg.go.dev/google.golang.org/protobuf/types/known/structpb#Struct"
"title": "https://github.com/golang/protobuf/issues/1118\r\nhttps://pkg.go.dev/google.golang.org/protobuf/types/known/structpb#Struct"
},
"clustermanagerWebAnnotationsV2": {
"type": "object",
Expand Down Expand Up @@ -18655,23 +18655,23 @@
"properties": {
"type_url": {
"type": "string",
"description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
"description": "A URL/resource name that uniquely identifies the type of the serialized\r\nprotocol buffer message. This string must contain at least\r\none \"/\" character. The last segment of the URL's path must represent\r\nthe fully qualified name of the type (as in\r\n`path/google.protobuf.Duration`). The name should be in a canonical form\r\n(e.g., leading \".\" is not accepted).\r\n\r\nIn practice, teams usually precompile into the binary all types that they\r\nexpect it to use in the context of Any. However, for URLs which use the\r\nscheme `http`, `https`, or no scheme, one can optionally set up a type\r\nserver that maps type URLs to message definitions as follows:\r\n\r\n* If no scheme is provided, `https` is assumed.\r\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\r\n value in binary format, or produce an error.\r\n* Applications are allowed to cache lookup results based on the\r\n URL, or have them precompiled into a binary to avoid any\r\n lookup. Therefore, binary compatibility needs to be preserved\r\n on changes to types. (Use versioned type names to manage\r\n breaking changes.)\r\n\r\nNote: this functionality is not currently available in the official\r\nprotobuf release, and it is not used for type URLs beginning with\r\ntype.googleapis.com.\r\n\r\nSchemes other than `http`, `https` (or the empty scheme) might be\r\nused with implementation specific semantics."
},
"value": {
"type": "string",
"format": "byte",
"description": "Must be a valid serialized protocol buffer of the above specified type."
}
},
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := ptypes.MarshalAny(foo)\n ...\n foo := \u0026pb.Foo{}\n if err := ptypes.UnmarshalAny(any, foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }"
"title": "`Any` contains an arbitrary serialized protocol buffer message along with a\r\nURL that describes the type of the serialized message.\r\n\r\nProtobuf library provides support to pack/unpack Any values in the form\r\nof utility functions or additional generated methods of the Any type.\r\n\r\nExample 1: Pack and unpack a message in C++.\r\n\r\n Foo foo = ...;\r\n Any any;\r\n any.PackFrom(foo);\r\n ...\r\n if (any.UnpackTo(\u0026foo)) {\r\n ...\r\n }\r\n\r\nExample 2: Pack and unpack a message in Java.\r\n\r\n Foo foo = ...;\r\n Any any = Any.pack(foo);\r\n ...\r\n if (any.is(Foo.class)) {\r\n foo = any.unpack(Foo.class);\r\n }\r\n\r\n Example 3: Pack and unpack a message in Python.\r\n\r\n foo = Foo(...)\r\n any = Any()\r\n any.Pack(foo)\r\n ...\r\n if any.Is(Foo.DESCRIPTOR):\r\n any.Unpack(foo)\r\n ...\r\n\r\n Example 4: Pack and unpack a message in Go\r\n\r\n foo := \u0026pb.Foo{...}\r\n any, err := ptypes.MarshalAny(foo)\r\n ...\r\n foo := \u0026pb.Foo{}\r\n if err := ptypes.UnmarshalAny(any, foo); err != nil {\r\n ...\r\n }\r\n\r\nThe pack methods provided by protobuf library will by default use\r\n'type.googleapis.com/full.type.name' as the type URL and the unpack\r\nmethods only use the fully qualified type name after the last '/'\r\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\r\nname \"y.z\".\r\n\r\n\r\nJSON\r\n====\r\nThe JSON representation of an `Any` value uses the regular\r\nrepresentation of the deserialized, embedded message, with an\r\nadditional field `@type` which contains the type URL. Example:\r\n\r\n package google.profile;\r\n message Person {\r\n string first_name = 1;\r\n string last_name = 2;\r\n }\r\n\r\n {\r\n \"@type\": \"type.googleapis.com/google.profile.Person\",\r\n \"firstName\": \u003cstring\u003e,\r\n \"lastName\": \u003cstring\u003e\r\n }\r\n\r\nIf the embedded message type is well-known and has a custom JSON\r\nrepresentation, that representation will be embedded adding a field\r\n`value` which holds the custom JSON in addition to the `@type`\r\nfield. Example (for message [google.protobuf.Duration][]):\r\n\r\n {\r\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\r\n \"value\": \"1.212s\"\r\n }"
},
"protobufNullValue": {
"type": "string",
"enum": [
"NULL_VALUE"
],
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
"description": "`NullValue` is a singleton enumeration to represent the null value for the\r\n`Value` type union.\r\n\r\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"runtimeError": {
"type": "object",
Expand Down
19 changes: 11 additions & 8 deletions bcs-services/bcs-cluster-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.376
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.544
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.714
go.mongodb.org/mongo-driver v1.5.3
go.mongodb.org/mongo-driver v1.12.0
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21
google.golang.org/grpc v1.49.0
google.golang.org/protobuf v1.28.1
Expand All @@ -70,6 +70,7 @@ require (
github.com/Tencent/bk-bcs/bcs-common/pkg/i18n v0.0.0-20230908142111-fef103db0120
github.com/apparentlymart/go-cidr v1.1.0
github.com/aws/aws-sdk-go v1.44.332
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.85
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tag v1.0.768
Expand Down Expand Up @@ -122,7 +123,6 @@ require (
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
Expand Down Expand Up @@ -164,6 +164,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/montanaflynn/stats v0.7.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
Expand All @@ -181,11 +182,12 @@ require (
github.com/spf13/cobra v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/streadway/amqp v1.0.0 // indirect
github.com/tjfoc/gmsm v1.4.1 // indirect
github.com/ugorji/go/codec v1.2.3 // indirect
github.com/xanzy/ssh-agent v0.3.2 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.0.2 // indirect
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.opencensus.io v0.23.0 // indirect
Expand All @@ -198,17 +200,18 @@ require (
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/cli-runtime v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* limitations under the License.
*/

// Package eop xxx
package eop

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

// Package api xxx
package api

import (
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region"

"github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/cloudprovider"
)

// CceClient cce client
type CceClient struct {
*cce.CceClient
}

// NewCceClient init cce client
func NewCceClient(opt *cloudprovider.CommonOption) (*CceClient, error) {
if opt == nil || opt.Account == nil || len(opt.Account.SecretID) == 0 || len(opt.Account.SecretKey) == 0 {
return nil, cloudprovider.ErrCloudCredentialLost
}
if len(opt.Region) == 0 {
return nil, cloudprovider.ErrCloudRegionLost
}

projectID, err := GetProjectIDByRegion(opt)
if err != nil {
return nil, err
}

auth, err := basic.NewCredentialsBuilder().WithAk(opt.Account.SecretID).WithSk(opt.Account.SecretKey).
WithProjectId(projectID).SafeBuild()
if err != nil {
return nil, err
}

rn, err := region.SafeValueOf(opt.Region)
if err != nil {
return nil, err
}

// 创建CCE client
hcClient, err := cce.CceClientBuilder().WithCredential(auth).WithRegion(rn).SafeBuild()
if err != nil {
return nil, err
}

return &CceClient{
CceClient: cce.NewCceClient(hcClient),
}, nil
}

// ListCceCluster get cce cluster list, region parameter init tke client
func (cli *CceClient) ListCceCluster() (*model.ListClustersResponse, error) {
if cli == nil {
return nil, cloudprovider.ErrServerIsNil
}

req := model.ListClustersRequest{}
rsp, err := cli.ListClusters(&req)
if err != nil {
return nil, err
}

return rsp, nil
}

// GetCceCluster get cce cluster
func (cli *CceClient) GetCceCluster(clusterID string) (*model.ShowClusterResponse, error) {
if cli == nil {
return nil, cloudprovider.ErrServerIsNil
}

req := model.ShowClusterRequest{
ClusterId: clusterID,
}
rsp, err := cli.ShowCluster(&req)
if err != nil {
return nil, err
}

return rsp, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

// Package api xxx
package api

import (
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
ecs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ecs/v2"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ecs/v2/model"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ecs/v2/region"

"github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/cloudprovider"
)

// EcsClient ecs client
type EcsClient struct {
*ecs.EcsClient
}

// NewEcsClient new ecs client
func NewEcsClient(opt *cloudprovider.CommonOption) (*EcsClient, error) {
if opt == nil || opt.Account == nil || len(opt.Account.SecretID) == 0 || len(opt.Account.SecretKey) == 0 {
return nil, cloudprovider.ErrCloudCredentialLost
}
if len(opt.Region) == 0 {
return nil, cloudprovider.ErrCloudRegionLost
}

projectID, err := GetProjectIDByRegion(opt)
if err != nil {
return nil, err
}

auth, err := basic.NewCredentialsBuilder().WithAk(opt.Account.SecretID).WithSk(opt.Account.SecretKey).
WithProjectId(projectID).SafeBuild()
if err != nil {
return nil, err
}

rn, err := region.SafeValueOf(opt.Region)
if err != nil {
return nil, err
}

hcClient, err := ecs.EcsClientBuilder().
WithCredential(auth).
WithRegion(rn). //指定region区域
SafeBuild()
if err != nil {
return nil, err
}

return &EcsClient{&ecs.EcsClient{HcClient: hcClient}}, nil
}

// GetAvailabilityZones 获取region可用区
func GetAvailabilityZones(opt *cloudprovider.CommonOption) ([]model.NovaAvailabilityZone, error) {
client, err := NewEcsClient(opt)
if err != nil {
return nil, err
}

rsp, err := client.NovaListAvailabilityZones(&model.NovaListAvailabilityZonesRequest{})
if err != nil {
return nil, err
}

return *rsp.AvailabilityZoneInfo, nil
}
Loading
Loading