MCPcopy Create free account
hub / github.com/cloudbase/garm / paramsJobToWorkflowJob

Method paramsJobToWorkflowJob

database/sql/jobs.go:77–116  ·  view source on GitHub ↗
(ctx context.Context, conn *gorm.DB, job params.Job)

Source from the content-addressed store, hash-verified

75}
76
77func (s *sqlDatabase) paramsJobToWorkflowJob(ctx context.Context, conn *gorm.DB, job params.Job) (WorkflowJob, error) {
78 asJSON, err := json.Marshal(job.Labels)
79 if err != nil {
80 return WorkflowJob{}, fmt.Errorf("error marshaling labels: %w", err)
81 }
82
83 workflofJob := WorkflowJob{
84 ScaleSetJobID: job.ScaleSetJobID,
85 WorkflowJobID: job.WorkflowJobID,
86 RunID: job.RunID,
87 Action: job.Action,
88 Status: job.Status,
89 Name: job.Name,
90 Conclusion: job.Conclusion,
91 StartedAt: job.StartedAt,
92 CompletedAt: job.CompletedAt,
93 GithubRunnerID: job.GithubRunnerID,
94 RunnerGroupID: job.RunnerGroupID,
95 RunnerGroupName: job.RunnerGroupName,
96 RepositoryName: job.RepositoryName,
97 RepositoryOwner: job.RepositoryOwner,
98 RepoID: job.RepoID,
99 OrgID: job.OrgID,
100 EnterpriseID: job.EnterpriseID,
101 Labels: asJSON,
102 LockedBy: job.LockedBy,
103 }
104
105 if job.RunnerName != "" {
106 instance, err := s.getInstance(s.ctx, conn, job.RunnerName)
107 if err != nil {
108 // This usually is very normal as not all jobs run on our runners.
109 slog.DebugContext(ctx, "failed to get instance by name", "instance_name", job.RunnerName)
110 } else {
111 workflofJob.InstanceID = &instance.ID
112 }
113 }
114
115 return workflofJob, nil
116}
117
118func (s *sqlDatabase) DeleteJob(_ context.Context, jobID int64) error {
119 var removedJob params.Job

Callers 1

CreateOrUpdateJobMethod · 0.95

Calls 2

getInstanceMethod · 0.95
MarshalMethod · 0.45

Tested by

no test coverage detected