-
Notifications
You must be signed in to change notification settings - Fork 51
/
config.go
43 lines (37 loc) · 1.26 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
package dockermonitor
import (
"go.aporeto.io/trireme-lib/monitor/constants"
"go.aporeto.io/trireme-lib/monitor/extractors"
)
// Config is the configuration options to start a CNI monitor
type Config struct {
EventMetadataExtractor extractors.DockerMetadataExtractor
SocketType string
SocketAddress string
SyncAtStart bool
KillContainerOnPolicyError bool
}
// DefaultConfig provides a default configuration
func DefaultConfig() *Config {
return &Config{
EventMetadataExtractor: extractors.DefaultMetadataExtractor,
SocketType: string(constants.DefaultDockerSocketType),
SocketAddress: constants.DefaultDockerSocket,
SyncAtStart: true,
KillContainerOnPolicyError: false,
}
}
// SetupDefaultConfig adds defaults to a partial configuration
func SetupDefaultConfig(dockerConfig *Config) *Config {
defaultConfig := DefaultConfig()
if dockerConfig.EventMetadataExtractor == nil {
dockerConfig.EventMetadataExtractor = defaultConfig.EventMetadataExtractor
}
if dockerConfig.SocketType == "" {
dockerConfig.SocketType = defaultConfig.SocketType
}
if dockerConfig.SocketAddress == "" {
dockerConfig.SocketAddress = defaultConfig.SocketAddress
}
return dockerConfig
}