diff --git a/src/api/rest/docs/docs.go b/src/api/rest/docs/docs.go index d151bdba9..06d338292 100644 --- a/src/api/rest/docs/docs.go +++ b/src/api/rest/docs/docs.go @@ -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" diff --git a/src/api/rest/docs/swagger.json b/src/api/rest/docs/swagger.json index b90247ead..ad126b01f 100644 --- a/src/api/rest/docs/swagger.json +++ b/src/api/rest/docs/swagger.json @@ -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" diff --git a/src/api/rest/docs/swagger.yaml b/src/api/rest/docs/swagger.yaml index e807924ef..90df97696 100644 --- a/src/api/rest/docs/swagger.yaml +++ b/src/api/rest/docs/swagger.yaml @@ -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 diff --git a/src/core/model/k8scluster.go b/src/core/model/k8scluster.go index 02375bb8a..6e105442f 100644 --- a/src/core/model/k8scluster.go +++ b/src/core/model/k8scluster.go @@ -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 diff --git a/src/core/resource/k8scluster.go b/src/core/resource/k8scluster.go index 592ba7b2f..5e42089ff 100644 --- a/src/core/resource/k8scluster.go +++ b/src/core/resource/k8scluster.go @@ -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{} */ @@ -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, }