-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
109 lines (91 loc) · 2.35 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package vivoupdater
import (
"errors"
"fmt"
"strings"
)
// stole code from here: https://godoc.org/github.com/namsral/flag
type CSV []string
type KafkaConfig struct {
BootstrapFlag CSV
//Topics CSV
MetricsTopic string
UpdatesTopic string
ClientCert string
ClientKey string
ServerCert string
ClientId string
GroupName string
}
type VaultConfig struct {
Endpoint string
RoleId string
SecretId string
AppId string
Token string
}
type Secrets struct {
KafkaClientKey string `mapstructure:"kafka_clientKey"`
KafkaClientCert string `mapstructure:"kafka_clientCert"`
KafkaServerCert string `mapstructure:"kafka_serverCert"`
}
func SecretsMap(appEnv string) map[string]string {
secrets := make(map[string]string, 3)
secrets["kafka.clientKey"] = fmt.Sprintf("apps/scholars/%s/kafka/clientKey", appEnv)
secrets["kafka.clientCert"] = fmt.Sprintf("apps/scholars/%s/kafka/clientCert", appEnv)
secrets["kafka.serverCert"] = fmt.Sprintf("apps/scholars/%s/kafka/serverCert", appEnv)
return secrets
}
// vivo
var VivoIndexerUrl string
var VivoEmail string
var VivoPassword string
// widgets
var WidgetsIndexerBaseUrl string
var WidgetsUser string
var WidgetsPassword string
// misc
var BatchSize int
var BatchTimeout int
var AppEnvironment string
// TODO: get rid of notification values entirely?
var NotificationSmtp string
var NotificationFrom string
var NotificationEmail CSV
// logging
var LogFile string
var LogMaxSize int
var LogMaxBackups int
var LogMaxAge int
// kafka
var BootstrapFlag CSV
//var Topics CSV
var UpdatesTopic string
var MetricsTopic string
var ClientCert string
var ClientKey string
var ServerCert string
var ClientId string
var GroupName string
// vault
var VaultEndpoint string
var VaultKey string
var VaultRoleId string
var VaultSecretId string
// String is the method to format the flag's value, part of the flag.Value interface.
// The String method's output will be used in diagnostics.
func (c *CSV) String() string {
return fmt.Sprint(*c)
}
// Set is the method to set the flag value, part of the flag.Value interface.
// Set's argument is a string to be parsed to set the flag.
// It's a comma-separated list, so we split it.
func (c *CSV) Set(value string) error {
if len(*c) > 0 {
return errors.New("flag already set")
}
for _, dt := range strings.Split(value, ",") {
*c = append(*c, dt)
}
return nil
}