( ctx context.Context, session *auth.Session, repoRef string, pipelineIdentifier string, executionNum int64, )
| 27 | ) |
| 28 | |
| 29 | func (c *Controller) Cancel( |
| 30 | ctx context.Context, |
| 31 | session *auth.Session, |
| 32 | repoRef string, |
| 33 | pipelineIdentifier string, |
| 34 | executionNum int64, |
| 35 | ) (*types.Execution, error) { |
| 36 | repo, err := c.getRepoCheckPipelineAccess( |
| 37 | ctx, |
| 38 | session, |
| 39 | repoRef, |
| 40 | pipelineIdentifier, |
| 41 | enum.PermissionPipelineExecute, |
| 42 | ) |
| 43 | if err != nil { |
| 44 | return nil, err |
| 45 | } |
| 46 | |
| 47 | pipeline, err := c.pipelineStore.FindByIdentifier(ctx, repo.ID, pipelineIdentifier) |
| 48 | if err != nil { |
| 49 | return nil, fmt.Errorf("failed to find pipeline: %w", err) |
| 50 | } |
| 51 | |
| 52 | execution, err := c.executionStore.FindByNumber(ctx, pipeline.ID, executionNum) |
| 53 | if err != nil { |
| 54 | return nil, fmt.Errorf("failed to find execution %d: %w", executionNum, err) |
| 55 | } |
| 56 | |
| 57 | err = c.canceler.Cancel(ctx, repo, execution) |
| 58 | if err != nil { |
| 59 | return nil, fmt.Errorf("unable to cancel execution: %w", err) |
| 60 | } |
| 61 | |
| 62 | // Write to the checks store, log and ignore on errors |
| 63 | err = checks.Write(ctx, c.checkStore, execution, pipeline) |
| 64 | if err != nil { |
| 65 | log.Ctx(ctx).Warn().Err(err).Msg("could not update status check") |
| 66 | } |
| 67 | |
| 68 | return execution, nil |
| 69 | } |
nothing calls this directly
no test coverage detected