-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck.go
53 lines (43 loc) · 1007 Bytes
/
check.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
package check
import (
"time"
"github.com/ParetoSecurity/pareto-core/shared"
)
var AvailableChecks = 0
type Check interface {
Name() string
PassedMessage() string
FailedMessage() string
Run() error
Passed() bool
IsRunnable() bool
UUID() string
Status() string
RequiresRoot() bool
}
func Register(c Check) Check {
AvailableChecks = +1
// If the check is already in the checks map, return it
if found := shared.Config.Checks[c.UUID()]; found != (shared.CheckStatus{}) {
return c
}
// If the checks map is nil, create it
if shared.Config.Checks == nil {
shared.Config.Checks = make(map[string]shared.CheckStatus)
}
// Add the check to the checks map
shared.Config.Checks[c.UUID()] = shared.CheckStatus{
UpdatedAt: time.Now(),
Passed: c.Passed(),
Disabled: !c.IsRunnable(),
}
return c
}
func Update(c Check) Check {
shared.Config.Checks[c.UUID()] = shared.CheckStatus{
UpdatedAt: time.Now(),
Passed: c.Passed(),
Disabled: !c.IsRunnable(),
}
return c
}