-
Notifications
You must be signed in to change notification settings - Fork 51
/
config.go
40 lines (32 loc) · 1.02 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
package uidmonitor
import (
"github.com/aporeto-inc/trireme-lib/monitor/extractors"
)
// Config is the configuration options to start a CNI monitor
type Config struct {
EventMetadataExtractor extractors.EventMetadataExtractor
StoredPath string
ReleasePath string
}
// DefaultConfig provides default configuration for uid monitor
func DefaultConfig() *Config {
return &Config{
EventMetadataExtractor: extractors.UIDMetadataExtractor,
StoredPath: "/var/run/trireme_uid",
ReleasePath: "/var/lib/aporeto/cleaner",
}
}
// SetupDefaultConfig adds defaults to a partial configuration
func SetupDefaultConfig(uidConfig *Config) *Config {
defaultConfig := DefaultConfig()
if uidConfig.ReleasePath == "" {
uidConfig.ReleasePath = defaultConfig.ReleasePath
}
if uidConfig.StoredPath == "" {
uidConfig.StoredPath = defaultConfig.StoredPath
}
if uidConfig.EventMetadataExtractor == nil {
uidConfig.EventMetadataExtractor = defaultConfig.EventMetadataExtractor
}
return uidConfig
}