tenseleyflow/shithub / c3b4552

Browse files

actions/events: satisfy lifecycle lint (S41h)

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
c3b4552d1c21a8b3cb697dc5bd6debe349440e6d
Parents
06ca804
Tree
38d6193

2 changed files

StatusFile+-
M internal/actions/lifecycle/cancel.go 2 3
M internal/web/handlers/api/runners.go 4 3
internal/actions/lifecycle/cancel.gomodified
@@ -51,8 +51,7 @@ func CancelRun(ctx context.Context, deps Deps, runID int64, reason string) (Canc
51
 		}
51
 		}
52
 	}()
52
 	}()
53
 
53
 
54
-	run, err := q.GetWorkflowRunByID(ctx, tx, runID)
54
+	if _, err := q.GetWorkflowRunByID(ctx, tx, runID); err != nil {
55
-	if err != nil {
56
 		return CancelResult{}, err
55
 		return CancelResult{}, err
57
 	}
56
 	}
58
 	changed, err := q.RequestWorkflowRunCancel(ctx, tx, runID)
57
 	changed, err := q.RequestWorkflowRunCancel(ctx, tx, runID)
@@ -75,7 +74,7 @@ func CancelRun(ctx context.Context, deps Deps, runID int64, reason string) (Canc
75
 		if err != nil {
74
 		if err != nil {
76
 			return CancelResult{}, err
75
 			return CancelResult{}, err
77
 		}
76
 		}
78
-		run, err = q.GetWorkflowRunByID(ctx, tx, runID)
77
+		run, err := q.GetWorkflowRunByID(ctx, tx, runID)
79
 		if err != nil {
78
 		if err != nil {
80
 			return CancelResult{}, err
79
 			return CancelResult{}, err
81
 		}
80
 		}
internal/web/handlers/api/runners.gomodified
@@ -222,16 +222,17 @@ func (h *Handlers) claimRunnerJob(
222
 		return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, nil
222
 		return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, nil
223
 	}
223
 	}
224
 	run, err := q.StartWorkflowRun(ctx, tx, job.RunID)
224
 	run, err := q.StartWorkflowRun(ctx, tx, job.RunID)
225
-	if err == nil {
225
+	switch {
226
+	case err == nil:
226
 		if err := actionsevents.EmitRunTx(ctx, tx, run, actionsevents.ActionRunning); err != nil {
227
 		if err := actionsevents.EmitRunTx(ctx, tx, run, actionsevents.ActionRunning); err != nil {
227
 			return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
228
 			return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
228
 		}
229
 		}
229
-	} else if errors.Is(err, pgx.ErrNoRows) {
230
+	case errors.Is(err, pgx.ErrNoRows):
230
 		run, err = q.GetWorkflowRunByID(ctx, tx, job.RunID)
231
 		run, err = q.GetWorkflowRunByID(ctx, tx, job.RunID)
231
 		if err != nil {
232
 		if err != nil {
232
 			return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
233
 			return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
233
 		}
234
 		}
234
-	} else {
235
+	default:
235
 		return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
236
 		return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
236
 	}
237
 	}
237
 	if err := actionsevents.EmitJobTx(ctx, tx, run, claimRowWorkflowJob(job), actionsevents.ActionRunning); err != nil {
238
 	if err := actionsevents.EmitJobTx(ctx, tx, run, claimRowWorkflowJob(job), actionsevents.ActionRunning); err != nil {