-
Notifications
You must be signed in to change notification settings - Fork 51
/
config.go
54 lines (43 loc) · 1.39 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
package linuxmonitor
import (
"go.aporeto.io/trireme-lib/common"
"go.aporeto.io/trireme-lib/monitor/extractors"
)
// Config is the configuration options to start a CNI monitor
type Config struct {
EventMetadataExtractor extractors.EventMetadataExtractor
StoredPath string
ReleasePath string
Host bool
}
// DefaultConfig provides a default configuration
func DefaultConfig(host bool) *Config {
if host {
return &Config{
EventMetadataExtractor: extractors.DefaultHostMetadataExtractor,
ReleasePath: "/var/lib/aporeto/cleaner",
StoredPath: common.TriremeCgroupPath,
Host: host,
}
}
return &Config{
EventMetadataExtractor: extractors.DefaultHostMetadataExtractor,
ReleasePath: "/var/lib/aporeto/cleaner",
StoredPath: common.TriremeCgroupPath,
Host: host,
}
}
// SetupDefaultConfig adds defaults to a partial configuration
func SetupDefaultConfig(linuxConfig *Config) *Config {
defaultConfig := DefaultConfig(linuxConfig.Host)
if linuxConfig.ReleasePath == "" {
linuxConfig.ReleasePath = defaultConfig.ReleasePath
}
if linuxConfig.EventMetadataExtractor == nil {
linuxConfig.EventMetadataExtractor = defaultConfig.EventMetadataExtractor
}
if linuxConfig.StoredPath == "" {
linuxConfig.StoredPath = common.TriremeCgroupPath
}
return linuxConfig
}