You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

podslistlogic.go 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package cloud
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
  5. v1 "k8s.io/api/core/v1"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  9. )
  10. type PodsListLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. type ParticipantResp struct {
  16. Code int `json:"code"`
  17. Msg string `json:"message"`
  18. Data *v1.PodList `json:"data"` // 改成结构体
  19. }
  20. func NewPodsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PodsListLogic {
  21. return &PodsListLogic{
  22. Logger: logx.WithContext(ctx),
  23. ctx: ctx,
  24. svcCtx: svcCtx,
  25. }
  26. }
  27. func (l *PodsListLogic) PodsList(req *types.PodsListReq) (resp *types.PodsListResp, err error) {
  28. resp = &types.PodsListResp{}
  29. // query cluster http url.
  30. var apiServerList []string
  31. l.svcCtx.DbEngin.Raw("select server from t_adapter where resource_type = '01'").Scan(&apiServerList)
  32. for _, server := range apiServerList {
  33. participantResp := ParticipantResp{}
  34. param := map[string]string{
  35. "clusterName": req.ClusterName,
  36. }
  37. httputils.HttpGetWithResult(param, server+"/api/v1/pod/list", &participantResp)
  38. resp.Data = append(resp.Data, participantResp.Data)
  39. }
  40. return resp, nil
  41. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.