-
Notifications
You must be signed in to change notification settings - Fork 4
/
result.go
35 lines (29 loc) · 909 Bytes
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package doctor
type Result struct {
Check *Check `json:"-"`
Key string `json:"key"`
Title string `json:"title"`
Status string `json:"status,omitempty"`
Summary string `json:"summary,omitempty"`
Errors Errors `json:"errors,omitempty"`
Duration int `json:"duration,omitempty"`
Solution []string `json:"solution,omitempty"`
Logs []string `json:"logs,omitempty"`
}
func NewResult(check *Check, key string, title string, summary string) *Result {
return &Result{Check: check, Key: key, Title: title, Status: "OK", Summary: summary}
}
func (p *Result) AddLog(msg string) *Result {
p.Logs = append(p.Logs, msg)
return p
}
func (p *Result) WithError(err *Error) *Result {
p.Status = "error"
p.Errors = append(p.Errors, err)
return p
}
func (p *Result) AddSolution(msg string) *Result {
p.Solution = append(p.Solution, msg)
return p
}
type Results []*Result