添加注释
Former-commit-id: e4e7b5685f762ae409b9af456c212234e8ed8a66
This commit is contained in:
parent
14014ee229
commit
f0da81de10
|
@ -26,6 +26,7 @@ func NewOctopusLink(ctx context.Context, svcCtx *svc.ServiceContext, platform st
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) UploadImage(path string) (interface{}, error) {
|
func (o *OctopusLink) UploadImage(path string) (interface{}, error) {
|
||||||
|
// octopus创建镜像
|
||||||
createReq := &octopus.CreateImageReq{
|
createReq := &octopus.CreateImageReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
CreateImage: &octopus.CreateImage{
|
CreateImage: &octopus.CreateImage{
|
||||||
|
@ -38,6 +39,8 @@ func (o *OctopusLink) UploadImage(path string) (interface{}, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// octopus上传镜像
|
||||||
uploadReq := &octopus.UploadImageReq{
|
uploadReq := &octopus.UploadImageReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
ImageId: createResp.Payload.ImageId,
|
ImageId: createResp.Payload.ImageId,
|
||||||
|
@ -51,6 +54,9 @@ func (o *OctopusLink) UploadImage(path string) (interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Todo 实际上传
|
||||||
|
|
||||||
|
//转换成统一返回类型
|
||||||
resp, err := ConvertType[octopus.UploadImageResp](uploadResp)
|
resp, err := ConvertType[octopus.UploadImageResp](uploadResp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -60,6 +66,7 @@ func (o *OctopusLink) UploadImage(path string) (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) DeleteImage(imageId string) (interface{}, error) {
|
func (o *OctopusLink) DeleteImage(imageId string) (interface{}, error) {
|
||||||
|
// octopus删除镜像
|
||||||
req := &octopus.DeleteImageReq{
|
req := &octopus.DeleteImageReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
ImageId: imageId,
|
ImageId: imageId,
|
||||||
|
@ -69,6 +76,7 @@ func (o *OctopusLink) DeleteImage(imageId string) (interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//转换成统一返回类型
|
||||||
deleteResp, err := ConvertType[octopus.DeleteImageResp](resp)
|
deleteResp, err := ConvertType[octopus.DeleteImageResp](resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -78,6 +86,7 @@ func (o *OctopusLink) DeleteImage(imageId string) (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) QueryImageList() (interface{}, error) {
|
func (o *OctopusLink) QueryImageList() (interface{}, error) {
|
||||||
|
// octopus获取镜像列表
|
||||||
req := &octopus.GetUserImageListReq{
|
req := &octopus.GetUserImageListReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
PageIndex: o.pageIndex,
|
PageIndex: o.pageIndex,
|
||||||
|
@ -88,6 +97,7 @@ func (o *OctopusLink) QueryImageList() (interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//转换成统一返回类型
|
||||||
imgListResp, err := ConvertType[octopus.GetUserImageListResp](resp)
|
imgListResp, err := ConvertType[octopus.GetUserImageListResp](resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -97,6 +107,7 @@ func (o *OctopusLink) QueryImageList() (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string) (interface{}, error) {
|
func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string) (interface{}, error) {
|
||||||
|
// octopus提交任务
|
||||||
req := &octopus.CreateTrainJobReq{
|
req := &octopus.CreateTrainJobReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
Params: &octopus.CreateTrainJobParam{
|
Params: &octopus.CreateTrainJobParam{
|
||||||
|
@ -119,6 +130,7 @@ func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string) (int
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//转换成统一返回类型
|
||||||
submitResp, err := ConvertType[octopus.CreateTrainJobResp](resp)
|
submitResp, err := ConvertType[octopus.CreateTrainJobResp](resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -128,6 +140,7 @@ func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string) (int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) QueryTask(taskId string) (interface{}, error) {
|
func (o *OctopusLink) QueryTask(taskId string) (interface{}, error) {
|
||||||
|
// octopus获取任务
|
||||||
req := &octopus.GetTrainJobReq{
|
req := &octopus.GetTrainJobReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
Id: taskId,
|
Id: taskId,
|
||||||
|
@ -137,6 +150,7 @@ func (o *OctopusLink) QueryTask(taskId string) (interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//转换成统一返回类型
|
||||||
taskResp, err := ConvertType[octopus.GetTrainJobResp](resp)
|
taskResp, err := ConvertType[octopus.GetTrainJobResp](resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -146,6 +160,7 @@ func (o *OctopusLink) QueryTask(taskId string) (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) DeleteTask(taskId string) (interface{}, error) {
|
func (o *OctopusLink) DeleteTask(taskId string) (interface{}, error) {
|
||||||
|
// octopus删除任务
|
||||||
req := &octopus.DeleteTrainJobReq{
|
req := &octopus.DeleteTrainJobReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
JobIds: []string{taskId},
|
JobIds: []string{taskId},
|
||||||
|
@ -155,6 +170,7 @@ func (o *OctopusLink) DeleteTask(taskId string) (interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//转换成统一返回类型
|
||||||
deleteResp, err := ConvertType[octopus.DeleteTrainJobResp](resp)
|
deleteResp, err := ConvertType[octopus.DeleteTrainJobResp](resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -33,6 +33,7 @@ type StoreLink struct {
|
||||||
ILinkage Linkage
|
ILinkage Linkage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo 根据participantId 创建对应对象
|
||||||
func NewStoreLink(ctx context.Context, svcCtx *svc.ServiceContext, partId int64) *StoreLink {
|
func NewStoreLink(ctx context.Context, svcCtx *svc.ServiceContext, partId int64) *StoreLink {
|
||||||
linkStruct := NewOctopusLink(ctx, svcCtx, "hanwuji")
|
linkStruct := NewOctopusLink(ctx, svcCtx, "hanwuji")
|
||||||
return &StoreLink{ILinkage: linkStruct}
|
return &StoreLink{ILinkage: linkStruct}
|
||||||
|
|
Loading…
Reference in New Issue