Skip to content

Commit

Permalink
Start the tencent cloud support.
Browse files Browse the repository at this point in the history
Signed-off-by: corvofeng <corvofeng@gmail.com>
  • Loading branch information
corvofeng committed May 22, 2024
1 parent a8d5d68 commit 6755fdb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.9.0
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.926
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.926
github.com/tj/assert v0.0.3
gopkg.in/yaml.v2 v2.4.0
k8s.io/client-go v0.30.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.926 h1:BkDvT4vINdfH9ZVwrALBCePGKyDDizHWXChz6KHmVE8=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.926/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.926 h1:I/rhxgpFTTkJpLUFOqm3TvLs8o6Z+7FaJdgWjl7KHl0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.926/go.mod h1:A27RdNJsRcAU+SEiygcpZ5IbsZPQVEhN+WRs4qyE9yk=
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
35 changes: 35 additions & 0 deletions lib/cloud_provider/km_tencent_cloud/tke.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package kmtencentcloud

import (
"fmt"
"os"

"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/regions"
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
)

func xx() {
// 硬编码密钥到代码中有可能随代码泄露而暴露,有安全隐患,并不推荐。
// 为了保护密钥安全,建议将密钥设置在环境变量中或者配置文件中,请参考本文凭证管理章节。
// credential := common.NewCredential("SecretId", "SecretKey")
credential := common.NewCredential(
os.Getenv("TENCENTCLOUD_SECRET_ID"),
os.Getenv("TENCENTCLOUD_SECRET_KEY"),
)
client, _ := cvm.NewClient(credential, regions.Singapore, profile.NewClientProfile())

request := cvm.NewDescribeInstancesRequest()
response, err := client.DescribeInstances(request)

if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
if err != nil {
panic(err)
}
fmt.Printf("%s\n", response.ToJsonString())
}
7 changes: 7 additions & 0 deletions lib/cloud_provider/km_tencent_cloud/tke_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package kmtencentcloud

import "testing"

func TestXX(t *testing.T) {
xx()
}

0 comments on commit 6755fdb

Please sign in to comment.