-
Notifications
You must be signed in to change notification settings - Fork 51
/
parameters.go
46 lines (37 loc) · 1.15 KB
/
parameters.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
package env
import (
"os"
"strconv"
"go.aporeto.io/enforcerd/trireme-lib/controller/constants"
"go.aporeto.io/enforcerd/trireme-lib/controller/pkg/claimsheader"
)
// RemoteParameters holds all configuration objects that must be passed
// during the initialization of the monitor.
type RemoteParameters struct {
LogWithID bool
LogLevel string
LogFormat string
CompressedTags claimsheader.CompressionType
}
// GetParameters retrieves log parameters for Remote Enforcer.
func GetParameters() (string, string, string, claimsheader.CompressionType, int) {
var logID, logLevel, logFormat string
var compressedTagsVersion claimsheader.CompressionType
var numQueues int
logLevel = os.Getenv(constants.EnvLogLevel)
if logLevel == "" {
logLevel = "info"
}
logFormat = os.Getenv(constants.EnvLogFormat)
if logLevel == "" {
logFormat = "json"
}
logID = os.Getenv(constants.EnvLogID)
compressedTagsVersion = claimsheader.CompressionTypeV1
if num, err := strconv.Atoi(os.Getenv(constants.EnvEnforcerdNFQueues)); err == nil {
numQueues = num
} else {
numQueues = 4
}
return logID, logLevel, logFormat, compressedTagsVersion, numQueues
}