-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
48 lines (44 loc) · 1.61 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
package etcdutil
const (
// DefaultTimeout is default etcd connection timeout.
DefaultTimeout = "2s"
)
var (
// DefaultEndpoints is default etcd servers.
DefaultEndpoints = []string{"http://127.0.0.1:2379"}
)
// Config represents configuration parameters to access etcd.
type Config struct {
// Endpoints are etcd servers.
Endpoints []string `json:"endpoints" toml:"endpoints"`
// Prefix is etcd prefix key.
Prefix string `json:"prefix" toml:"prefix"`
// Timeout is dial timeout of the etcd client connection.
Timeout string `json:"timeout" toml:"timeout"`
// Username is username for loging in to the etcd.
Username string `json:"username" toml:"username"`
// Password is password for loging in to the etcd.
Password string `json:"password" toml:"password"`
// TLSCAFile is root CA path.
TLSCAFile string `json:"tls-ca-file" toml:"tls-ca-file"`
// TLSCA is root CA raw string.
TLSCA string `json:"tls-ca" toml:"tls-ca"`
// TLSCertFile is TLS client certificate path.
TLSCertFile string `json:"tls-cert-file" toml:"tls-cert-file"`
// TLSCert is TLS client certificate raw string.
TLSCert string `json:"tls-cert" toml:"tls-cert"`
// TLSKeyFile is TLS client private key.
TLSKeyFile string `json:"tls-key-file" toml:"tls-key-file"`
// TLSKey is TLS client private key raw string.
TLSKey string `json:"tls-key" toml:"tls-key"`
}
// NewConfig creates Config with default values.
func NewConfig(prefix string) *Config {
defaultEndpoints := make([]string, len(DefaultEndpoints))
copy(defaultEndpoints, DefaultEndpoints)
return &Config{
Endpoints: defaultEndpoints,
Prefix: prefix,
Timeout: DefaultTimeout,
}
}