(ctx context.Context, s *store.Store, taskRun *store.TaskRunMessage)
| 36 | } |
| 37 | |
| 38 | func convertToTaskRun(ctx context.Context, s *store.Store, taskRun *store.TaskRunMessage) (*v1pb.TaskRun, error) { |
| 39 | stageID := common.FormatStageID(taskRun.Environment) |
| 40 | t := &v1pb.TaskRun{ |
| 41 | Name: common.FormatTaskRun(taskRun.ProjectID, taskRun.PlanUID, stageID, taskRun.TaskUID, taskRun.ID), |
| 42 | Creator: common.FormatUserEmail(taskRun.CreatorEmail), |
| 43 | CreateTime: timestamppb.New(taskRun.CreatedAt), |
| 44 | UpdateTime: timestamppb.New(taskRun.UpdatedAt), |
| 45 | Status: convertToTaskRunStatus(taskRun.Status), |
| 46 | Detail: taskRun.ResultProto.Detail, |
| 47 | } |
| 48 | if taskRun.StartedAt != nil { |
| 49 | t.StartTime = timestamppb.New(*taskRun.StartedAt) |
| 50 | } |
| 51 | if taskRun.RunAt != nil { |
| 52 | t.RunTime = timestamppb.New(*taskRun.RunAt) |
| 53 | } |
| 54 | |
| 55 | if taskRun.PayloadProto != nil && taskRun.PayloadProto.SchedulerInfo != nil { |
| 56 | t.SchedulerInfo = convertToSchedulerInfo(taskRun.PayloadProto.SchedulerInfo) |
| 57 | } |
| 58 | |
| 59 | if taskRun.ResultProto.ExportArchiveId != "" { |
| 60 | t.ExportArchiveStatus = v1pb.TaskRun_EXPORTED |
| 61 | exportArchiveID := taskRun.ResultProto.ExportArchiveId |
| 62 | exportArchive, err := s.GetExportArchive(ctx, common.GetWorkspaceIDFromContext(ctx), exportArchiveID) |
| 63 | if err != nil { |
| 64 | return nil, errors.Wrapf(err, "failed to get export archive") |
| 65 | } |
| 66 | if exportArchive != nil { |
| 67 | t.ExportArchiveStatus = v1pb.TaskRun_READY |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | t.HasPriorBackup = taskRun.ResultProto.HasPriorBackup |
| 72 | |
| 73 | return t, nil |
| 74 | } |
| 75 | |
| 76 | func convertToSchedulerInfo(si *storepb.SchedulerInfo) *v1pb.TaskRun_SchedulerInfo { |
| 77 | if si == nil { |
no test coverage detected