-
Notifications
You must be signed in to change notification settings - Fork 2
/
postprocess.go
41 lines (35 loc) · 699 Bytes
/
postprocess.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
package main
import (
"regexp"
)
func postprocessResult(r *ResultMap, params LinterParams) error {
pattern := params.SkipContainerPattern
if len(pattern) == 0 {
return nil
}
re, err := regexp.Compile(pattern)
if err != nil {
return err
}
//iterate over map keys
for k, v := range *r {
//iterate over values
replace := false
s := []ContainerSpec{} //zero-length slice, _not_ nil, so JSON encoder writes []
for _, spec := range v {
container := spec.Container
if len(container) == 0 {
continue
}
if re.FindStringIndex(spec.Container) != nil {
replace = true
} else {
s = append(s, spec)
}
}
if replace {
(*r)[k] = s
}
}
return nil
}