From 9154727023d6dea98c19c92b11e46bf9663fb327 Mon Sep 17 00:00:00 2001 From: Sooyoung Kim Date: Wed, 20 Nov 2024 02:44:04 +0000 Subject: [PATCH] FIX: [k8scluster] update k8scluster info from CB-SP fixes #1933 --- src/core/model/k8scluster.go | 6 +++--- src/core/resource/k8scluster.go | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/core/model/k8scluster.go b/src/core/model/k8scluster.go index 49b418e3..5b4a534b 100644 --- a/src/core/model/k8scluster.go +++ b/src/core/model/k8scluster.go @@ -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. @@ -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 diff --git a/src/core/resource/k8scluster.go b/src/core/resource/k8scluster.go index f0d6395c..27ff404e 100644 --- a/src/core/resource/k8scluster.go +++ b/src/core/resource/k8scluster.go @@ -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 @@ -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) } }