chickenlj commented on code in PR #286:
URL: https://github.com/apache/dubbo-kubernetes/pull/286#discussion_r1609404126


##########
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:
   Should we only set the map `instMap[instName] = instanceDetail` in the 
`else` branch above?



##########
pkg/admin/model/instance.go:
##########
@@ -73,3 +78,105 @@ type State struct {
        Tip   string `json:"tip"`
        Value string `json:"value"`
 }
+
+type InstanceDetailResp struct {
+       RpcPort         []string `json:"rpcPort"`
+       Ip              []string `json:"ip"`
+       AppName         []string `json:"appName"`
+       WorkloadName    []string `json:"workloadName"`
+       Labels          []string `json:"labels"`
+       CreateTime      []string `json:"createTime"`
+       ReadyTime       []string `json:"readyTime"`
+       RegisterTime    []string `json:"registerTime"`
+       RegisterCluster []string `json:"registerCluster"`
+       DeployCluster   []string `json:"deployCluster"`
+       Node            []string `json:"node"`
+       Image           []string `json:"image"`
+       Probes          struct {
+               StartupProbe struct {
+                       Type string `json:"type"`
+                       Port int    `json:"port"`
+                       Open bool   `json:"open"`
+               } `json:"startupProbe"`
+               ReadinessProbe struct {
+                       Type string `json:"type"`
+                       Port int    `json:"port"`
+                       Open bool   `json:"open"`
+               } `json:"readinessProbe"`
+               LivenessProbe struct {
+                       Type string `json:"type"`
+                       Port int    `json:"port"`
+                       Open bool   `json:"open"`
+               } `json:"livenessProbe"`
+       } `json:"probes"`
+}
+
+func (r *InstanceDetailResp) FromInstanceDetail(id *InstanceDetail) 
*InstanceDetailResp {
+       r.AppName = id.AppName.Values()
+       r.RpcPort = id.RpcPort.Values()
+       r.Ip = id.Ip.Values()
+       r.WorkloadName = id.WorkloadName.Values()
+       r.Labels = id.Labels.Values()
+       r.CreateTime = id.CreateTime.Values()
+       r.ReadyTime = id.ReadyTime.Values()
+       r.RegisterTime = id.RegisterTime.Values()
+       r.RegisterCluster = id.RegisterClusters.Values()
+       r.DeployCluster = id.DeployCluster.Values()
+       r.Node = id.Node.Values()
+       r.Image = id.Image.Values()
+       return r
+}
+
+type InstanceDetail struct {
+       RpcPort          Set
+       Ip               Set
+       AppName          Set
+       WorkloadName     Set
+       Labels           Set
+       CreateTime       Set
+       ReadyTime        Set
+       RegisterTime     Set
+       RegisterClusters Set
+       DeployCluster    Set
+       Node             Set
+       Image            Set
+}

Review Comment:
   Why are all fields here declared as `Set`? 



##########
conf/dubbo-cp.yaml:
##########
@@ -1,4 +1,4 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
+# Licensed to the Apache Software Foundation (ASF) under one or moreshop-use

Review Comment:
   Please check if this is an unexpected change.



-- 
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