-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.go
59 lines (46 loc) · 1.24 KB
/
results.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package cmd
import "fmt"
// an enum for what an auditResult can be
type auditResultType int
const (
RESULT_DEBUG auditResultType = iota
RESULT_INFO
RESULT_WARNING
RESULT_ERROR
)
// auditResults are what a policy audit can return. These can be notes, debug information, warnings, and most importantly, errors.
type auditResult struct {
repository *wardenRepo
resultType auditResultType
message string
values []any
}
// Properly print out a result
func (this auditResult) String() string {
return fmt.Sprintf(this.message, this.values...)
}
// the list of results returned from the audit
type auditResults []auditResult
// adds a new result
func (this *auditResults) add(repo *wardenRepo, resultType auditResultType, message string, values ...any) {
*this = append(*this, auditResult{
repo,
resultType,
message,
values,
})
}
// Returns a subset, just the one type
func (this *auditResults) ByType(resultType auditResultType) auditResults {
var results auditResults
for _, result := range *this {
if result.resultType == resultType {
results = append(results, result)
}
}
return results
}
// combine two auditResults together
func (this *auditResults) merge(results auditResults) {
*this = append(*this, results...)
}