Go · 11168 bytes Raw Blame History
1 // Code generated by sqlc. DO NOT EDIT.
2 // versions:
3 // sqlc v1.31.1
4 // source: workflow_steps.sql
5
6 package actionsdb
7
8 import (
9 "context"
10
11 "github.com/jackc/pgx/v5/pgtype"
12 )
13
14 const cancelOpenWorkflowStepsForJob = `-- name: CancelOpenWorkflowStepsForJob :many
15 UPDATE workflow_steps
16 SET status = 'cancelled',
17 conclusion = 'cancelled',
18 started_at = COALESCE(started_at, now()),
19 completed_at = COALESCE(completed_at, now()),
20 version = version + 1,
21 updated_at = now()
22 WHERE job_id = $1
23 AND status IN ('queued', 'running')
24 RETURNING id, job_id, step_index, step_id, step_name, if_expr,
25 run_command, uses_alias, working_directory, step_env,
26 continue_on_error, status, conclusion, log_object_key,
27 log_byte_count, started_at, completed_at, version,
28 created_at, updated_at, step_with
29 `
30
31 func (q *Queries) CancelOpenWorkflowStepsForJob(ctx context.Context, db DBTX, jobID int64) ([]WorkflowStep, error) {
32 rows, err := db.Query(ctx, cancelOpenWorkflowStepsForJob, jobID)
33 if err != nil {
34 return nil, err
35 }
36 defer rows.Close()
37 items := []WorkflowStep{}
38 for rows.Next() {
39 var i WorkflowStep
40 if err := rows.Scan(
41 &i.ID,
42 &i.JobID,
43 &i.StepIndex,
44 &i.StepID,
45 &i.StepName,
46 &i.IfExpr,
47 &i.RunCommand,
48 &i.UsesAlias,
49 &i.WorkingDirectory,
50 &i.StepEnv,
51 &i.ContinueOnError,
52 &i.Status,
53 &i.Conclusion,
54 &i.LogObjectKey,
55 &i.LogByteCount,
56 &i.StartedAt,
57 &i.CompletedAt,
58 &i.Version,
59 &i.CreatedAt,
60 &i.UpdatedAt,
61 &i.StepWith,
62 ); err != nil {
63 return nil, err
64 }
65 items = append(items, i)
66 }
67 if err := rows.Err(); err != nil {
68 return nil, err
69 }
70 return items, nil
71 }
72
73 const getFirstStepForJob = `-- name: GetFirstStepForJob :one
74 SELECT id, job_id, step_index, step_id, step_name, if_expr,
75 run_command, uses_alias, working_directory, step_env,
76 continue_on_error, status, conclusion, log_object_key,
77 log_byte_count, started_at, completed_at, version,
78 created_at, updated_at, step_with
79 FROM workflow_steps
80 WHERE job_id = $1
81 ORDER BY step_index ASC
82 LIMIT 1
83 `
84
85 func (q *Queries) GetFirstStepForJob(ctx context.Context, db DBTX, jobID int64) (WorkflowStep, error) {
86 row := db.QueryRow(ctx, getFirstStepForJob, jobID)
87 var i WorkflowStep
88 err := row.Scan(
89 &i.ID,
90 &i.JobID,
91 &i.StepIndex,
92 &i.StepID,
93 &i.StepName,
94 &i.IfExpr,
95 &i.RunCommand,
96 &i.UsesAlias,
97 &i.WorkingDirectory,
98 &i.StepEnv,
99 &i.ContinueOnError,
100 &i.Status,
101 &i.Conclusion,
102 &i.LogObjectKey,
103 &i.LogByteCount,
104 &i.StartedAt,
105 &i.CompletedAt,
106 &i.Version,
107 &i.CreatedAt,
108 &i.UpdatedAt,
109 &i.StepWith,
110 )
111 return i, err
112 }
113
114 const getWorkflowStepByID = `-- name: GetWorkflowStepByID :one
115 SELECT id, job_id, step_index, step_id, step_name, if_expr,
116 run_command, uses_alias, working_directory, step_env,
117 continue_on_error, status, conclusion, log_object_key,
118 log_byte_count, started_at, completed_at, version,
119 created_at, updated_at, step_with
120 FROM workflow_steps
121 WHERE id = $1
122 `
123
124 func (q *Queries) GetWorkflowStepByID(ctx context.Context, db DBTX, id int64) (WorkflowStep, error) {
125 row := db.QueryRow(ctx, getWorkflowStepByID, id)
126 var i WorkflowStep
127 err := row.Scan(
128 &i.ID,
129 &i.JobID,
130 &i.StepIndex,
131 &i.StepID,
132 &i.StepName,
133 &i.IfExpr,
134 &i.RunCommand,
135 &i.UsesAlias,
136 &i.WorkingDirectory,
137 &i.StepEnv,
138 &i.ContinueOnError,
139 &i.Status,
140 &i.Conclusion,
141 &i.LogObjectKey,
142 &i.LogByteCount,
143 &i.StartedAt,
144 &i.CompletedAt,
145 &i.Version,
146 &i.CreatedAt,
147 &i.UpdatedAt,
148 &i.StepWith,
149 )
150 return i, err
151 }
152
153 const insertWorkflowStep = `-- name: InsertWorkflowStep :one
154
155 INSERT INTO workflow_steps (
156 job_id, step_index, step_id, step_name, if_expr,
157 run_command, uses_alias, working_directory, step_env, continue_on_error,
158 step_with
159 ) VALUES (
160 $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11
161 )
162 RETURNING id, job_id, step_index, step_id, step_name, if_expr,
163 run_command, uses_alias, working_directory, step_env,
164 continue_on_error, status, conclusion, log_object_key,
165 log_byte_count, started_at, completed_at, version,
166 created_at, updated_at, step_with
167 `
168
169 type InsertWorkflowStepParams struct {
170 JobID int64
171 StepIndex int32
172 StepID string
173 StepName string
174 IfExpr string
175 RunCommand string
176 UsesAlias string
177 WorkingDirectory string
178 StepEnv []byte
179 ContinueOnError bool
180 StepWith []byte
181 }
182
183 // SPDX-License-Identifier: AGPL-3.0-or-later
184 func (q *Queries) InsertWorkflowStep(ctx context.Context, db DBTX, arg InsertWorkflowStepParams) (WorkflowStep, error) {
185 row := db.QueryRow(ctx, insertWorkflowStep,
186 arg.JobID,
187 arg.StepIndex,
188 arg.StepID,
189 arg.StepName,
190 arg.IfExpr,
191 arg.RunCommand,
192 arg.UsesAlias,
193 arg.WorkingDirectory,
194 arg.StepEnv,
195 arg.ContinueOnError,
196 arg.StepWith,
197 )
198 var i WorkflowStep
199 err := row.Scan(
200 &i.ID,
201 &i.JobID,
202 &i.StepIndex,
203 &i.StepID,
204 &i.StepName,
205 &i.IfExpr,
206 &i.RunCommand,
207 &i.UsesAlias,
208 &i.WorkingDirectory,
209 &i.StepEnv,
210 &i.ContinueOnError,
211 &i.Status,
212 &i.Conclusion,
213 &i.LogObjectKey,
214 &i.LogByteCount,
215 &i.StartedAt,
216 &i.CompletedAt,
217 &i.Version,
218 &i.CreatedAt,
219 &i.UpdatedAt,
220 &i.StepWith,
221 )
222 return i, err
223 }
224
225 const listRunnerStepsForJob = `-- name: ListRunnerStepsForJob :many
226 SELECT id, job_id, step_index, step_id, step_name, if_expr,
227 run_command, uses_alias, working_directory, step_env,
228 continue_on_error, status, conclusion, log_byte_count,
229 started_at, completed_at, created_at, step_with
230 FROM workflow_steps
231 WHERE job_id = $1
232 ORDER BY step_index ASC
233 `
234
235 type ListRunnerStepsForJobRow struct {
236 ID int64
237 JobID int64
238 StepIndex int32
239 StepID string
240 StepName string
241 IfExpr string
242 RunCommand string
243 UsesAlias string
244 WorkingDirectory string
245 StepEnv []byte
246 ContinueOnError bool
247 Status WorkflowStepStatus
248 Conclusion NullCheckConclusion
249 LogByteCount int64
250 StartedAt pgtype.Timestamptz
251 CompletedAt pgtype.Timestamptz
252 CreatedAt pgtype.Timestamptz
253 StepWith []byte
254 }
255
256 func (q *Queries) ListRunnerStepsForJob(ctx context.Context, db DBTX, jobID int64) ([]ListRunnerStepsForJobRow, error) {
257 rows, err := db.Query(ctx, listRunnerStepsForJob, jobID)
258 if err != nil {
259 return nil, err
260 }
261 defer rows.Close()
262 items := []ListRunnerStepsForJobRow{}
263 for rows.Next() {
264 var i ListRunnerStepsForJobRow
265 if err := rows.Scan(
266 &i.ID,
267 &i.JobID,
268 &i.StepIndex,
269 &i.StepID,
270 &i.StepName,
271 &i.IfExpr,
272 &i.RunCommand,
273 &i.UsesAlias,
274 &i.WorkingDirectory,
275 &i.StepEnv,
276 &i.ContinueOnError,
277 &i.Status,
278 &i.Conclusion,
279 &i.LogByteCount,
280 &i.StartedAt,
281 &i.CompletedAt,
282 &i.CreatedAt,
283 &i.StepWith,
284 ); err != nil {
285 return nil, err
286 }
287 items = append(items, i)
288 }
289 if err := rows.Err(); err != nil {
290 return nil, err
291 }
292 return items, nil
293 }
294
295 const listStepsForJob = `-- name: ListStepsForJob :many
296 SELECT id, job_id, step_index, step_id, step_name, run_command,
297 uses_alias, status, conclusion, log_object_key, log_byte_count,
298 started_at, completed_at, created_at, updated_at
299 FROM workflow_steps
300 WHERE job_id = $1
301 ORDER BY step_index ASC
302 `
303
304 type ListStepsForJobRow struct {
305 ID int64
306 JobID int64
307 StepIndex int32
308 StepID string
309 StepName string
310 RunCommand string
311 UsesAlias string
312 Status WorkflowStepStatus
313 Conclusion NullCheckConclusion
314 LogObjectKey pgtype.Text
315 LogByteCount int64
316 StartedAt pgtype.Timestamptz
317 CompletedAt pgtype.Timestamptz
318 CreatedAt pgtype.Timestamptz
319 UpdatedAt pgtype.Timestamptz
320 }
321
322 func (q *Queries) ListStepsForJob(ctx context.Context, db DBTX, jobID int64) ([]ListStepsForJobRow, error) {
323 rows, err := db.Query(ctx, listStepsForJob, jobID)
324 if err != nil {
325 return nil, err
326 }
327 defer rows.Close()
328 items := []ListStepsForJobRow{}
329 for rows.Next() {
330 var i ListStepsForJobRow
331 if err := rows.Scan(
332 &i.ID,
333 &i.JobID,
334 &i.StepIndex,
335 &i.StepID,
336 &i.StepName,
337 &i.RunCommand,
338 &i.UsesAlias,
339 &i.Status,
340 &i.Conclusion,
341 &i.LogObjectKey,
342 &i.LogByteCount,
343 &i.StartedAt,
344 &i.CompletedAt,
345 &i.CreatedAt,
346 &i.UpdatedAt,
347 ); err != nil {
348 return nil, err
349 }
350 items = append(items, i)
351 }
352 if err := rows.Err(); err != nil {
353 return nil, err
354 }
355 return items, nil
356 }
357
358 const updateWorkflowStepLogObject = `-- name: UpdateWorkflowStepLogObject :one
359 UPDATE workflow_steps
360 SET log_object_key = $1::text,
361 log_byte_count = $2::bigint,
362 version = version + 1,
363 updated_at = now()
364 WHERE id = $3::bigint
365 RETURNING id, job_id, step_index, step_id, step_name, if_expr,
366 run_command, uses_alias, working_directory, step_env,
367 continue_on_error, status, conclusion, log_object_key,
368 log_byte_count, started_at, completed_at, version,
369 created_at, updated_at, step_with
370 `
371
372 type UpdateWorkflowStepLogObjectParams struct {
373 LogObjectKey pgtype.Text
374 LogByteCount int64
375 ID int64
376 }
377
378 func (q *Queries) UpdateWorkflowStepLogObject(ctx context.Context, db DBTX, arg UpdateWorkflowStepLogObjectParams) (WorkflowStep, error) {
379 row := db.QueryRow(ctx, updateWorkflowStepLogObject, arg.LogObjectKey, arg.LogByteCount, arg.ID)
380 var i WorkflowStep
381 err := row.Scan(
382 &i.ID,
383 &i.JobID,
384 &i.StepIndex,
385 &i.StepID,
386 &i.StepName,
387 &i.IfExpr,
388 &i.RunCommand,
389 &i.UsesAlias,
390 &i.WorkingDirectory,
391 &i.StepEnv,
392 &i.ContinueOnError,
393 &i.Status,
394 &i.Conclusion,
395 &i.LogObjectKey,
396 &i.LogByteCount,
397 &i.StartedAt,
398 &i.CompletedAt,
399 &i.Version,
400 &i.CreatedAt,
401 &i.UpdatedAt,
402 &i.StepWith,
403 )
404 return i, err
405 }
406
407 const updateWorkflowStepStatus = `-- name: UpdateWorkflowStepStatus :one
408 UPDATE workflow_steps
409 SET status = $2,
410 conclusion = $3::check_conclusion,
411 started_at = $4::timestamptz,
412 completed_at = $5::timestamptz,
413 version = version + 1,
414 updated_at = now()
415 WHERE id = $1
416 RETURNING id, job_id, step_index, step_id, step_name, if_expr,
417 run_command, uses_alias, working_directory, step_env,
418 continue_on_error, status, conclusion, log_object_key,
419 log_byte_count, started_at, completed_at, version,
420 created_at, updated_at, step_with
421 `
422
423 type UpdateWorkflowStepStatusParams struct {
424 ID int64
425 Status WorkflowStepStatus
426 Conclusion NullCheckConclusion
427 StartedAt pgtype.Timestamptz
428 CompletedAt pgtype.Timestamptz
429 }
430
431 func (q *Queries) UpdateWorkflowStepStatus(ctx context.Context, db DBTX, arg UpdateWorkflowStepStatusParams) (WorkflowStep, error) {
432 row := db.QueryRow(ctx, updateWorkflowStepStatus,
433 arg.ID,
434 arg.Status,
435 arg.Conclusion,
436 arg.StartedAt,
437 arg.CompletedAt,
438 )
439 var i WorkflowStep
440 err := row.Scan(
441 &i.ID,
442 &i.JobID,
443 &i.StepIndex,
444 &i.StepID,
445 &i.StepName,
446 &i.IfExpr,
447 &i.RunCommand,
448 &i.UsesAlias,
449 &i.WorkingDirectory,
450 &i.StepEnv,
451 &i.ContinueOnError,
452 &i.Status,
453 &i.Conclusion,
454 &i.LogObjectKey,
455 &i.LogByteCount,
456 &i.StartedAt,
457 &i.CompletedAt,
458 &i.Version,
459 &i.CreatedAt,
460 &i.UpdatedAt,
461 &i.StepWith,
462 )
463 return i, err
464 }
465