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

Add csp connection info to k8s cluster info #1843

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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