This commit is contained in:
IT 老营长 @云轩领航-创始人 2025-02-14 16:52:40 +08:00
parent b5601d7a58
commit 9c66ee628e
8 changed files with 79 additions and 2 deletions

3
go.mod
View File

@ -15,6 +15,7 @@ require (
)
require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1095 // indirect
shylinux.com/x/go-git/v5 v5.6.7 // indirect
shylinux.com/x/go-qrcode v0.0.3 // indirect
shylinux.com/x/websocket v0.0.4 // indirect
@ -28,7 +29,7 @@ require (
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1051
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1095
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.1046
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/smh v1.0.1051
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.1047

4
go.sum
View File

@ -73,12 +73,16 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046/go.mod
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1047/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1051 h1:3mg0L9vv9eO8UN4Oa7vNawe6yUIuXf9D0Q79rUmnblo=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1051/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1095 h1:chwhz7qiknR6hz/gVpQszRSL2Bw/jXNz9dHmY0tWelE=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1095/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.1046 h1:P8TrTPEWu4GjnEMyNgdYmV5jXigGtDMn+sVTLJJvW0c=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.1046/go.mod h1:ifVagKrjnvy/ibrvLZjsELEh5WdRtchM8xyUlF88BNg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/smh v1.0.1051 h1:P7q/ROrOi/M/VzM4ADMeALj94zJaW/zIGvJ6xe5BBkw=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/smh v1.0.1051/go.mod h1:dVFt5mYSzAtQ2uLOBavl9G4KHrjJJOCLqtrzvW+h0tg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.1047 h1:FF8uERgTL9NKxgUHrKHbVefETVL3J6DeL9t6qvIT5yI=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.1047/go.mod h1:3tgFFSlybx6XyhvLWpnSjWYFMedTyQC9oyh8CH1Ak28=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1095 h1:l7SQnVkft1vPdfE/gv/ee2wBj54+hacPzchjs4gnGgw=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1095/go.mod h1:7V6/Y6tPk0jL21YAevsuDSBSN3nU5XFRBR6CFsTLhJE=
github.com/tinygo-org/cbgo v0.0.4/go.mod h1:7+HgWIHd4nbAz0ESjGlJ1/v9LDU1Ox8MGzP9mah/fLk=
github.com/tinygo-org/pio v0.0.0-20231216154340-cd888eb58899/go.mod h1:LU7Dw00NJ+N86QkeTGjMLNkYcEYMor6wTDpTCu0EaH8=
github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0=

View File

@ -9,6 +9,7 @@ import (
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/smh"
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/sms"
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/sms/model"
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/tke"
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentdocument"
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentdocument/model"
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentmeeting"

View File

@ -45,8 +45,10 @@ func (s Tencentcloud) ParseResponse(m *ice.Message, res interface{ ToJsonString(
}
func (s Tencentcloud) ParseResponseList(m *ice.Message, res interface{ ToJsonString() string }, err error, arg ...string) {
if !m.Warn(err) {
kit.For(kit.Value(kit.UnMarshal(res.ToJsonString()), kit.Select("Response.List", arg, 0)), func(value ice.Map) {
data := kit.UnMarshal(res.ToJsonString())
kit.For(kit.Value(data, kit.Select("Response.List", arg, 0)), func(value ice.Map) {
m.PushRecord(value, kit.Slice(arg, 1)...)
})
m.Echo(kit.Formats(data))
}
}

View File

@ -0,0 +1,41 @@
package tke
import (
"shylinux.com/x/ice"
"shylinux.com/x/community/src/renzhengshouquan"
"shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
sdk "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
)
type tke struct {
renzhengshouquan.Tables
tencentcloud.Tencentcloud
order string `data:"17"`
list string `name:"list auth_uid uid auto" help:"容器服务" role:"worker"`
}
func (s tke) List(m *ice.Message, arg ...string) {
if len(arg) == 1 {
request := sdk.NewDescribeClustersRequest()
response, err := s.newClient(m).DescribeClusters(request)
s.ParseResponseList(m, response, err, "Response.Clusters")
m.RenameAppend("ClusterId", "uid")
} else {
request := sdk.NewDescribeClusterInstancesRequest()
request.ClusterId = common.StringPtr(arg[1])
response, err := s.newClient(m).DescribeClusterInstances(request)
s.ParseResponseList(m, response, err, "Response.InstanceSet")
m.RenameAppend("ClusterId", "uid")
}
m.Display("")
}
func init() { ice.TeamCtxCmd(tke{}) }
func (s tke) newClient(m *ice.Message, arg ...string) *sdk.Client {
c, _ := sdk.NewClient(s.NewCredential(m), "ap-guangzhou", s.NewProfile(m))
return c
}

View File

@ -0,0 +1,15 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
if (!can.Option(UID)) {
can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.uid, value.ClusterName, can.onimport.titleAction(can, value)]},
{view: html.STATUS, list: [value.ClusterLevel, value.ClusterNodeNum, value.CreatedTime]}
] })
} else {
can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.InstanceId, value.LanIP, can.onimport.titleAction(can, value)]},
{view: html.STATUS, list: [value.InstanceState, value.CreatedTime]},
] })
}
},
})

View File

@ -0,0 +1,6 @@
{
"tke": "容器服务",
"icons": {
"tke": "https://img.icons8.com/officel/80/stack-of-photos.png"
}
}

View File

@ -0,0 +1,7 @@
chapter "容器服务"
refer `
官网 https://cloud.tencent.com/product/tke
文档 https://cloud.tencent.com/document/product/457
后台 https://console.cloud.tencent.com/tke2/overview
调试 https://console.cloud.tencent.com/api/explorer?Product=tke&Version=2018-05-25&Action=DescribeClusters
`