internal/control/output.go
57 lines · 1801 bytes
1package control
2
3// Named payloads for the commands other surfaces decode. A command used
4// to declare its output inline, so the web type-asserted map keys and
5// nothing tied what a command emits to what a client reads (#126).
6
7// Created is what issue create, issue comment and mr comment emit.
8type Created struct {
9 Number int64 `json:"number"`
10}
11
12// MRCreated is what mr create emits.
13type MRCreated struct {
14 Number int64 `json:"number"`
15 HeadSHA string `json:"head_sha"`
16 StackedOn *stackRef `json:"stacked_on,omitempty"`
17}
18
19// IssueShow is issue show's payload: the issue and its comments.
20type IssueShow struct {
21 issueOut
22 Comments []commentOut `json:"comments,omitempty"`
23}
24
25// MRShow is mr show's payload.
26type MRShow struct {
27 mrOut
28 Checks []CheckOut `json:"checks,omitempty"`
29 Combined string `json:"checks_combined,omitempty"`
30 UnresolvedThreads int `json:"unresolved_threads,omitempty"`
31 Commits []CommitOut `json:"commits,omitempty"`
32 Comments []commentOut `json:"comments,omitempty"`
33 Reviews []ReviewOut `json:"reviews,omitempty"`
34}
35
36// ReviewOut is one review on a merge request.
37type ReviewOut struct {
38 Reviewer string `json:"reviewer"`
39 Verdict string `json:"verdict"`
40 Stale bool `json:"stale"`
41 CreatedAt string `json:"created_at"`
42}
43
44// CheckOut is one commit status on a merge request head.
45type CheckOut struct {
46 Context string `json:"context"`
47 State string `json:"state"`
48 URL string `json:"url,omitempty"`
49 UpdatedAt string `json:"updated_at"`
50 Duration string `json:"duration,omitempty"` // CI checks only, once finished
51}
52
53// CommitOut is one commit a merge request carries.
54type CommitOut struct {
55 SHA string `json:"sha"`
56 Subject string `json:"subject"`
57}