Skip to content

Commit

Permalink
Add csp connection info to k8s cluster info
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-github-robot authored Oct 2, 2024
2 parents cb578d2 + 7362a15 commit 07e7c75
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12644,6 +12644,14 @@ const docTemplate = `{
"model.TbK8sClusterInfo": {
"type": "object",
"properties": {
"connectionConfig": {
"description": "ConnectionConfig shows connection info to cloud service provider",
"allOf": [
{
"$ref": "#/definitions/model.ConnConfig"
}
]
},
"connectionName": {
"type": "string",
"example": "alibaba-ap-northeast-2"
Expand Down
8 changes: 8 additions & 0 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -12638,6 +12638,14 @@
"model.TbK8sClusterInfo": {
"type": "object",
"properties": {
"connectionConfig": {
"description": "ConnectionConfig shows connection info to cloud service provider",
"allOf": [
{
"$ref": "#/definitions/model.ConnConfig"
}
]
},
"connectionName": {
"type": "string",
"example": "alibaba-ap-northeast-2"
Expand Down
5 changes: 5 additions & 0 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9391,6 +9391,11 @@ components:
model.TbK8sClusterInfo:
type: object
properties:
connectionConfig:
type: object
description: ConnectionConfig shows connection info to cloud service provider
allOf:
- $ref: '#/components/schemas/model.ConnConfig'
connectionName:
type: string
example: alibaba-ap-northeast-2
Expand Down
3 changes: 3 additions & 0 deletions src/core/model/k8scluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ type TbK8sClusterInfo struct {
Name string `json:"name" example:"aws-ap-southeast-1"`
ConnectionName string `json:"connectionName" example:"alibaba-ap-northeast-2"`

// ConnectionConfig shows connection info to cloud service provider
ConnectionConfig ConnConfig `json:"connectionConfig"`

/*
Version string `json:"version" example:"1.30.1-aliyun.1"` // Kubernetes Version, ex) 1.23.3
Expand Down
7 changes: 7 additions & 0 deletions src/core/resource/k8scluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func CreateK8sCluster(nsId string, req *model.TbK8sClusterReq, option string) (m
return emptyObj, err
}

connectionConfig, err := common.GetConnConfig(req.ConnectionName)
if err != nil {
err = fmt.Errorf("Cannot retrieve ConnectionConfig" + err.Error())
log.Error().Err(err).Msg("")
}

/*
* Build RequestBody for model.SpiderClusterReq{}
*/
Expand Down Expand Up @@ -265,6 +271,7 @@ func CreateK8sCluster(nsId string, req *model.TbK8sClusterReq, option string) (m
CspResourceId: spClusterRes.ClusterInfo.IId.SystemId,
Name: reqId,
ConnectionName: req.ConnectionName,
ConnectionConfig: connectionConfig,
Description: req.Description,
CspViewK8sClusterDetail: spClusterRes.ClusterInfo,
}
Expand Down

0 comments on commit 07e7c75

Please sign in to comment.