MCPcopy Create free account
hub / github.com/bytebase/bytebase / convertToTaskRun

Function convertToTaskRun

backend/api/v1/rollout_service_converter.go:38–74  ·  view source on GitHub ↗
(ctx context.Context, s *store.Store, taskRun *store.TaskRunMessage)

Source from the content-addressed store, hash-verified

36}
37
38func 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
76func convertToSchedulerInfo(si *storepb.SchedulerInfo) *v1pb.TaskRun_SchedulerInfo {
77 if si == nil {

Callers 2

GetTaskRunMethod · 0.85
convertToTaskRunsFunction · 0.85

Calls 7

FormatStageIDFunction · 0.92
FormatTaskRunFunction · 0.92
FormatUserEmailFunction · 0.92
convertToTaskRunStatusFunction · 0.85
convertToSchedulerInfoFunction · 0.85
GetExportArchiveMethod · 0.80

Tested by

no test coverage detected