镜像列表接口注释 开发中
Former-commit-id: 0df5d171dc5ae18ee9245d8d519bc9986694ff15
This commit is contained in:
parent
a13bf4782c
commit
d51c5aed55
|
@ -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")
|
//url := fmt.Sprintf("%s/repository/%s/v2/_catalog", l.svcCtx.Config.NexusUrl, "pcm")
|
||||||
bytes, err := tool.HttpClient("GET", url, nil, "")
|
//bytes, err := tool.HttpClient("GET", url, nil, "")
|
||||||
json.Unmarshal(bytes, &resp)
|
//json.Unmarshal(bytes, &resp)
|
||||||
result := types.ImageListResp{}
|
//result := types.ImageListResp{}
|
||||||
for _, image := range resp.Repositories {
|
//for _, image := range resp.Repositories {
|
||||||
// 获取镜像的tag列表
|
// // 获取镜像的tag列表
|
||||||
url := fmt.Sprintf("%s/repository/%s/v2/%s/tags/list", l.svcCtx.Config.NexusUrl, "pcm", image)
|
// url := fmt.Sprintf("registry.cn-hangzhou.aliyuncs.com/jointcloud/pcm:", image)
|
||||||
bytes, err := tool.HttpClient("GET", url, nil, "")
|
// bytes, err := tool.HttpClient("GET", url, nil, "")
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
tags := ImageTags{}
|
// tags := ImageTags{}
|
||||||
json.Unmarshal(bytes, &tags)
|
// json.Unmarshal(bytes, &tags)
|
||||||
// 拼接镜像名称
|
// // 拼接镜像名称
|
||||||
for _, tag := range tags.Tags {
|
// for _, tag := range tags.Tags {
|
||||||
var name string
|
// var name string
|
||||||
if tag != "latest" {
|
// if tag != "latest" {
|
||||||
name = "hub.jcce.dev:18445/" + image + ":" + tag
|
// name = "hub.jcce.dev:18445/" + image + ":" + tag
|
||||||
} else {
|
// } else {
|
||||||
name = "hub.jcce.dev:18445/" + image
|
// name = "hub.jcce.dev:18445/" + image
|
||||||
}
|
// }
|
||||||
result.Repositories = append(result.Repositories, name)
|
// result.Repositories = append(result.Repositories, name)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
return &result, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue