镜像列表接口注释 开发中
Former-commit-id: 0df5d171dc5ae18ee9245d8d519bc9986694ff15
This commit is contained in:
parent
a13bf4782c
commit
d51c5aed55
|
@ -3,10 +3,7 @@ package image
|
|||
import (
|
||||
"PCM/adaptor/PCM-CORE/api/internal/svc"
|
||||
"PCM/adaptor/PCM-CORE/api/internal/types"
|
||||
"PCM/common/tool"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"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) {
|
||||
|
||||
// 获取镜像列表
|
||||
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…
Reference in New Issue