-
Notifications
You must be signed in to change notification settings - Fork 41
/
config.go
45 lines (38 loc) · 1.09 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
package corral
import (
"github.com/spf13/viper"
)
func loadConfig() {
viper.SetConfigName("corralrc")
viper.AddConfigPath(".")
viper.AddConfigPath("$HOME/.corral")
setupDefaults()
viper.ReadInConfig()
viper.SetEnvPrefix("corral")
viper.AutomaticEnv()
}
func setupDefaults() {
defaultSettings := map[string]interface{}{
"lambdaFunctionName": "corral_function",
"lambdaMemory": 1500,
"lambdaTimeout": 180,
"lambdaManageRole": true,
"cleanup": true,
"verbose": false,
"splitSize": 100 * 1024 * 1024, // Default input split size is 100Mb
"mapBinSize": 512 * 1024 * 1024, // Default map bin size is 512Mb
"reduceBinSize": 512 * 1024 * 1024, // Default reduce bin size is 512Mb
"maxConcurrency": 500, // Maximum number of concurrent executors
"workingLocation": ".",
}
for key, value := range defaultSettings {
viper.SetDefault(key, value)
}
aliases := map[string]string{
"verbose": "v",
"working_location": "o",
}
for key, alias := range aliases {
viper.RegisterAlias(alias, key)
}
}