Skip to content

Commit

Permalink
FIX: [k8scluster] update k8scluster info from CB-SP
Browse files Browse the repository at this point in the history
fixes #1933
  • Loading branch information
Sooyoung Kim committed Nov 20, 2024
1 parent 9719e45 commit 9154727
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/core/model/k8scluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ type TbK8sClusterInfo struct {
// ResourceType is the type of the resource
ResourceType string `json:"resourceType"`

// Id is unique identifier for the object
Id string `json:"id" example:"aws-ap-southeast-1"`
// Id is unique identifier for the object, same as Name
Id string `json:"id" example:"k8scluster-01"`
// Uid is universally unique identifier for the object, used for labelSelector
Uid string `json:"uid,omitempty" example:"wef12awefadf1221edcf"`
// CspResourceName is name assigned to the CSP resource. This name is internally used to handle the resource.
Expand All @@ -314,7 +314,7 @@ type TbK8sClusterInfo struct {
CspResourceId string `json:"cspResourceId,omitempty" example:"csp-06eb41e14121c550a"`

// Name is human-readable string to represent the object
Name string `json:"name" example:"aws-ap-southeast-1"`
Name string `json:"name" example:"k8scluster-01"`
ConnectionName string `json:"connectionName" example:"alibaba-ap-northeast-2"`

// ConnectionConfig shows connection info to cloud service provider
Expand Down
13 changes: 10 additions & 3 deletions src/core/resource/k8scluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1081,8 +1081,8 @@ func ListK8sCluster(nsId string, filterKey string, filterVal string) (interface{

if kv != nil {
for _, v := range kv {
tbK8sCInfo := model.TbK8sClusterInfo{}
err = json.Unmarshal([]byte(v.Value), &tbK8sCInfo)
storedTbK8sCInfo := model.TbK8sClusterInfo{}
err = json.Unmarshal([]byte(v.Value), &storedTbK8sCInfo)
if err != nil {
log.Err(err).Msg("Failed to List K8sCluster")
return nil, err
Expand All @@ -1096,7 +1096,14 @@ func ListK8sCluster(nsId string, filterKey string, filterVal string) (interface{
continue
}
}
tbK8sCInfoList = append(tbK8sCInfoList, tbK8sCInfo)

tbK8sCInfo, err := GetK8sCluster(nsId, storedTbK8sCInfo.Id)
if err != nil {
log.Err(err).Msg("Failed to List K8sCluster")
continue
}

tbK8sCInfoList = append(tbK8sCInfoList, *tbK8sCInfo)
}
}

Expand Down

0 comments on commit 9154727

Please sign in to comment.