-
Notifications
You must be signed in to change notification settings - Fork 51
/
config.go
61 lines (50 loc) · 1.24 KB
/
config.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
package config
import (
"fmt"
"strings"
"github.com/aporeto-inc/trireme-lib/collector"
"github.com/aporeto-inc/trireme-lib/policy"
)
// Type specifies the type of monitors supported.
type Type int
// Types supported.
const (
CNI Type = iota + 1
Docker
LinuxProcess
LinuxHost
UID
)
// MonitorConfig specifies the configs for monitors.
type MonitorConfig struct {
Common *ProcessorConfig
MergeTags []string
Monitors map[Type]interface{}
}
// String returns the configuration in string
func (c *MonitorConfig) String() string {
buf := fmt.Sprintf("MergeTags:[%s] ", strings.Join(c.MergeTags, ","))
buf += fmt.Sprintf("Common:%+v ", c.Common)
buf += fmt.Sprintf("Monitors:{")
for k, v := range c.Monitors {
buf += fmt.Sprintf("{%d:%+v},", k, v)
}
buf += fmt.Sprintf("}")
return buf
}
// ProcessorConfig holds configuration for the processors
type ProcessorConfig struct {
Collector collector.EventCollector
Policy policy.Resolver
MergeTags []string
}
// IsComplete checks if configuration is complete
func (c *ProcessorConfig) IsComplete() error {
if c.Collector == nil {
return fmt.Errorf("Missing configuration: collector")
}
if c.Policy == nil {
return fmt.Errorf("Missing configuration: puHandler")
}
return nil
}