Browse Source

镜像列表接口注释 开发中

Former-commit-id: 0df5d171dc
pull/9/head
zhangwei 2 years ago
parent
commit
d51c5aed55
1 changed files with 25 additions and 28 deletions
  1. +25
    -28
      adaptor/PCM-CORE/api/internal/logic/image/imagelistlogic.go

+ 25
- 28
adaptor/PCM-CORE/api/internal/logic/image/imagelistlogic.go View File

@@ -3,10 +3,7 @@ package image
import ( import (
"PCM/adaptor/PCM-CORE/api/internal/svc" "PCM/adaptor/PCM-CORE/api/internal/svc"
"PCM/adaptor/PCM-CORE/api/internal/types" "PCM/adaptor/PCM-CORE/api/internal/types"
"PCM/common/tool"
"context" "context"
"encoding/json"
"fmt"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
) )


@@ -32,29 +29,29 @@ func NewImageListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ImageLi
func (l *ImageListLogic) ImageList() (resp *types.ImageListResp, err error) { func (l *ImageListLogic) ImageList() (resp *types.ImageListResp, err error) {


// 获取镜像列表 // 获取镜像列表
url := fmt.Sprintf("%s/repository/%s/v2/_catalog", l.svcCtx.Config.NexusUrl, "pcm")
bytes, err := tool.HttpClient("GET", url, nil, "")
json.Unmarshal(bytes, &resp)
result := types.ImageListResp{}
for _, image := range resp.Repositories {
// 获取镜像的tag列表
url := fmt.Sprintf("%s/repository/%s/v2/%s/tags/list", l.svcCtx.Config.NexusUrl, "pcm", image)
bytes, err := tool.HttpClient("GET", url, nil, "")
if err != nil {
return nil, err
}
tags := ImageTags{}
json.Unmarshal(bytes, &tags)
// 拼接镜像名称
for _, tag := range tags.Tags {
var name string
if tag != "latest" {
name = "hub.jcce.dev:18445/" + image + ":" + tag
} else {
name = "hub.jcce.dev:18445/" + image
}
result.Repositories = append(result.Repositories, name)
}
}
return &result, nil
//url := fmt.Sprintf("%s/repository/%s/v2/_catalog", l.svcCtx.Config.NexusUrl, "pcm")
//bytes, err := tool.HttpClient("GET", url, nil, "")
//json.Unmarshal(bytes, &resp)
//result := types.ImageListResp{}
//for _, image := range resp.Repositories {
// // 获取镜像的tag列表
// url := fmt.Sprintf("registry.cn-hangzhou.aliyuncs.com/jointcloud/pcm:", image)
// bytes, err := tool.HttpClient("GET", url, nil, "")
// if err != nil {
// return nil, err
// }
// tags := ImageTags{}
// json.Unmarshal(bytes, &tags)
// // 拼接镜像名称
// for _, tag := range tags.Tags {
// var name string
// if tag != "latest" {
// name = "hub.jcce.dev:18445/" + image + ":" + tag
// } else {
// name = "hub.jcce.dev:18445/" + image
// }
// result.Repositories = append(result.Repositories, name)
// }
//}
return nil, nil
} }

Loading…
Cancel
Save