MCPcopy
hub / github.com/harness/harness / Write

Function Write

app/pipeline/checks/write.go:30–71  ·  view source on GitHub ↗

Write is a util function which writes execution and pipeline state to the check store.

(
	ctx context.Context,
	checkStore store.CheckStore,
	execution *types.Execution,
	pipeline *types.Pipeline,
)

Source from the content-addressed store, hash-verified

28// Write is a util function which writes execution and pipeline state to the
29// check store.
30func Write(
31 ctx context.Context,
32 checkStore store.CheckStore,
33 execution *types.Execution,
34 pipeline *types.Pipeline,
35) error {
36 payload := types.CheckPayloadInternal{
37 Number: execution.Number,
38 RepoID: execution.RepoID,
39 PipelineID: execution.PipelineID,
40 }
41 data, err := json.Marshal(payload)
42 if err != nil {
43 return fmt.Errorf("could not marshal check payload: %w", err)
44 }
45 now := time.Now().UnixMilli()
46 summary := pipeline.Description
47 if summary == "" {
48 summary = pipeline.Identifier
49 }
50 check := &types.Check{
51 RepoID: execution.RepoID,
52 Identifier: pipeline.Identifier,
53 Summary: summary,
54 Created: now,
55 Updated: now,
56 CreatedBy: execution.CreatedBy,
57 Status: execution.Status.ConvertToCheckStatus(),
58 CommitSHA: execution.After,
59 Metadata: []byte("{}"),
60 Payload: types.CheckPayload{
61 Version: "1",
62 Kind: enum.CheckPayloadKindPipeline,
63 Data: data,
64 },
65 }
66 err = checkStore.Upsert(ctx, check)
67 if err != nil {
68 return fmt.Errorf("could not upsert to check store: %w", err)
69 }
70 return nil
71}

Callers 5

CancelMethod · 0.92
TriggerMethod · 0.92
doMethod · 0.92
doMethod · 0.92

Calls 3

ConvertToCheckStatusMethod · 0.80
UpsertMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…