Go · 4026 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 getWorkflowStepByID = `-- name: GetWorkflowStepByID :one
15 SELECT id, job_id, step_index, step_id, step_name, if_expr,
16 run_command, uses_alias, working_directory, step_env,
17 continue_on_error, status, conclusion, log_object_key,
18 log_byte_count, started_at, completed_at, version,
19 created_at, updated_at
20 FROM workflow_steps
21 WHERE id = $1
22 `
23
24 func (q *Queries) GetWorkflowStepByID(ctx context.Context, db DBTX, id int64) (WorkflowStep, error) {
25 row := db.QueryRow(ctx, getWorkflowStepByID, id)
26 var i WorkflowStep
27 err := row.Scan(
28 &i.ID,
29 &i.JobID,
30 &i.StepIndex,
31 &i.StepID,
32 &i.StepName,
33 &i.IfExpr,
34 &i.RunCommand,
35 &i.UsesAlias,
36 &i.WorkingDirectory,
37 &i.StepEnv,
38 &i.ContinueOnError,
39 &i.Status,
40 &i.Conclusion,
41 &i.LogObjectKey,
42 &i.LogByteCount,
43 &i.StartedAt,
44 &i.CompletedAt,
45 &i.Version,
46 &i.CreatedAt,
47 &i.UpdatedAt,
48 )
49 return i, err
50 }
51
52 const insertWorkflowStep = `-- name: InsertWorkflowStep :one
53
54 INSERT INTO workflow_steps (
55 job_id, step_index, step_id, step_name, if_expr,
56 run_command, uses_alias, working_directory, step_env, continue_on_error
57 ) VALUES (
58 $1, $2, $3, $4, $5, $6, $7, $8, $9, $10
59 )
60 RETURNING id, job_id, step_index, step_id, step_name, if_expr,
61 run_command, uses_alias, working_directory, step_env,
62 continue_on_error, status, conclusion, log_object_key,
63 log_byte_count, started_at, completed_at, version,
64 created_at, updated_at
65 `
66
67 type InsertWorkflowStepParams struct {
68 JobID int64
69 StepIndex int32
70 StepID string
71 StepName string
72 IfExpr string
73 RunCommand string
74 UsesAlias string
75 WorkingDirectory string
76 StepEnv []byte
77 ContinueOnError bool
78 }
79
80 // SPDX-License-Identifier: AGPL-3.0-or-later
81 func (q *Queries) InsertWorkflowStep(ctx context.Context, db DBTX, arg InsertWorkflowStepParams) (WorkflowStep, error) {
82 row := db.QueryRow(ctx, insertWorkflowStep,
83 arg.JobID,
84 arg.StepIndex,
85 arg.StepID,
86 arg.StepName,
87 arg.IfExpr,
88 arg.RunCommand,
89 arg.UsesAlias,
90 arg.WorkingDirectory,
91 arg.StepEnv,
92 arg.ContinueOnError,
93 )
94 var i WorkflowStep
95 err := row.Scan(
96 &i.ID,
97 &i.JobID,
98 &i.StepIndex,
99 &i.StepID,
100 &i.StepName,
101 &i.IfExpr,
102 &i.RunCommand,
103 &i.UsesAlias,
104 &i.WorkingDirectory,
105 &i.StepEnv,
106 &i.ContinueOnError,
107 &i.Status,
108 &i.Conclusion,
109 &i.LogObjectKey,
110 &i.LogByteCount,
111 &i.StartedAt,
112 &i.CompletedAt,
113 &i.Version,
114 &i.CreatedAt,
115 &i.UpdatedAt,
116 )
117 return i, err
118 }
119
120 const listStepsForJob = `-- name: ListStepsForJob :many
121 SELECT id, job_id, step_index, step_id, step_name, run_command,
122 uses_alias, status, conclusion, log_byte_count,
123 started_at, completed_at, created_at
124 FROM workflow_steps
125 WHERE job_id = $1
126 ORDER BY step_index ASC
127 `
128
129 type ListStepsForJobRow struct {
130 ID int64
131 JobID int64
132 StepIndex int32
133 StepID string
134 StepName string
135 RunCommand string
136 UsesAlias string
137 Status WorkflowStepStatus
138 Conclusion NullCheckConclusion
139 LogByteCount int64
140 StartedAt pgtype.Timestamptz
141 CompletedAt pgtype.Timestamptz
142 CreatedAt pgtype.Timestamptz
143 }
144
145 func (q *Queries) ListStepsForJob(ctx context.Context, db DBTX, jobID int64) ([]ListStepsForJobRow, error) {
146 rows, err := db.Query(ctx, listStepsForJob, jobID)
147 if err != nil {
148 return nil, err
149 }
150 defer rows.Close()
151 items := []ListStepsForJobRow{}
152 for rows.Next() {
153 var i ListStepsForJobRow
154 if err := rows.Scan(
155 &i.ID,
156 &i.JobID,
157 &i.StepIndex,
158 &i.StepID,
159 &i.StepName,
160 &i.RunCommand,
161 &i.UsesAlias,
162 &i.Status,
163 &i.Conclusion,
164 &i.LogByteCount,
165 &i.StartedAt,
166 &i.CompletedAt,
167 &i.CreatedAt,
168 ); err != nil {
169 return nil, err
170 }
171 items = append(items, i)
172 }
173 if err := rows.Err(); err != nil {
174 return nil, err
175 }
176 return items, nil
177 }
178