SHA-4096 commented on code in PR #286:
URL: https://github.com/apache/dubbo-kubernetes/pull/286#discussion_r1609878411


##########
pkg/admin/service/instance.go:
##########
@@ -43,3 +44,33 @@ func SearchInstances(rt core_runtime.Runtime, req 
*model.SearchInstanceReq) ([]*
 
        return res, &dataplaneList.Pagination, nil
 }
+
+func GetInstanceDetail(rt core_runtime.Runtime, req *model.InstanceDetailReq) 
([]*model.InstanceDetailResp, error) {
+       manager := rt.ResourceManager()
+       dataplaneList := &mesh.DataplaneResourceList{}
+
+       if err := manager.List(rt.AppContext(), dataplaneList, 
store.ListByNameContains(req.InstanceName)); err != nil {
+               return nil, err
+       }
+
+       instMap := make(map[string]*model.InstanceDetail)
+       for _, dataplane := range dataplaneList.Items {
+               instName := dataplane.Meta.GetLabels()[mesh_proto.InstanceTag]
+               var instanceDetail *model.InstanceDetail
+               if _, ok := instMap[instName]; ok {
+                       instanceDetail = instMap[instName]
+               } else {
+                       instanceDetail = model.NewInstanceDetail()
+               }
+               instanceDetail.Merge(dataplane) //convert dataplane info to 
instance detail
+               instMap[instName] = instanceDetail

Review Comment:
   The logic is ok in my opinion, considering the need for merging different 
information from the same instance. The explanation of the logic is shown in 
comments in this commit:  
https://github.com/apache/dubbo-kubernetes/pull/286/commits/e82fa817dc25b9cea2e50a2ecff9e071d8a33a20
  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to