-
Notifications
You must be signed in to change notification settings - Fork 427
/
helpers.go
76 lines (66 loc) · 1.1 KB
/
helpers.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package models
func (a *Alert) HasRemediation() bool {
return true
}
func (a *Alert) GetScope() string {
if a.Source.Scope == nil {
return ""
}
return *a.Source.Scope
}
func (a *Alert) GetValue() string {
if a.Source.Value == nil {
return ""
}
return *a.Source.Value
}
func (a *Alert) GetScenario() string {
if a.Scenario == nil {
return ""
}
return *a.Scenario
}
func (a *Alert) GetEventsCount() int32 {
if a.EventsCount == nil {
return 0
}
return *a.EventsCount
}
func (e *Event) GetMeta(key string) string {
for _, meta := range e.Meta {
if meta.Key == key {
return meta.Value
}
}
return ""
}
func (a *Alert) GetMeta(key string) string {
for _, meta := range a.Meta {
if meta.Key == key {
return meta.Value
}
}
return ""
}
func (s Source) GetValue() string {
if s.Value == nil {
return ""
}
return *s.Value
}
func (s Source) GetScope() string {
if s.Scope == nil {
return ""
}
return *s.Scope
}
func (s Source) GetAsNumberName() string {
ret := ""
if s.AsNumber != "0" {
ret += s.AsNumber
}
if s.AsName != "" {
ret += " " + s.AsName
}
return ret
}