forked from JointCloud/pcm-coordinator
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package storelink
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type SubmitLinkTaskLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitLinkTaskLogic {
|
|
return &SubmitLinkTaskLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) {
|
|
participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin)
|
|
storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant)
|
|
var envs []string
|
|
if len(req.Envs) != 0 {
|
|
for _, v := range req.Envs {
|
|
env := v.Key + storeLink.COMMA + v.Val
|
|
envs = append(envs, env)
|
|
}
|
|
}
|
|
task, err := storelink.ILinkage.SubmitTask(req.ImageId, req.Cmd, envs)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
taskResp := task.(types.SubmitLinkTaskResp)
|
|
return &taskResp, nil
|
|
}
|