MCPcopy
hub / github.com/harness/harness / Cancel

Method Cancel

app/api/controller/execution/cancel.go:29–69  ·  view source on GitHub ↗
(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pipelineIdentifier string,
	executionNum int64,
)

Source from the content-addressed store, hash-verified

27)
28
29func (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}

Callers

nothing calls this directly

Calls 9

WriteFunction · 0.92
MsgMethod · 0.80
FindByIdentifierMethod · 0.65
FindByNumberMethod · 0.65
CancelMethod · 0.65
ErrMethod · 0.65
WarnMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected