-
Notifications
You must be signed in to change notification settings - Fork 62
/
config.go
46 lines (38 loc) · 1.54 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
package redisnode
import (
"time"
"github.com/amadeusitgroup/redis-operator/pkg/config"
"github.com/spf13/pflag"
)
const (
// RedisStartWaitDefault default stop duration (sec)
RedisStartWaitDefault = 10 * time.Second
// RedisStartDelayDefault default start delay duration (sec)
RedisStartDelayDefault = 10 * time.Second
// HTTPServerAddrDefault default http server address
HTTPServerAddrDefault = "0.0.0.0:8080"
)
// Config contains configuration for redis-operator
type Config struct {
KubeConfigFile string
Master string
Redis config.Redis
Cluster config.Cluster
RedisStartWait time.Duration
RedisStartDelay time.Duration
HTTPServerAddr string
}
// NewRedisNodeConfig builds and returns a redis-operator Config
func NewRedisNodeConfig() *Config {
return &Config{}
}
// AddFlags add cobra flags to populate Config
func (c *Config) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&c.KubeConfigFile, "kubeconfig", c.KubeConfigFile, "Location of kubecfg file for access to kubernetes master service")
fs.StringVar(&c.Master, "master", c.Master, "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
fs.DurationVar(&c.RedisStartWait, "t", RedisStartWaitDefault, "Max time waiting for redis to start")
fs.DurationVar(&c.RedisStartDelay, "d", RedisStartDelayDefault, "delay before that the redis-server is started")
fs.StringVar(&c.HTTPServerAddr, "http-addr", HTTPServerAddrDefault, "the http server listen address")
c.Redis.AddFlags(fs)
c.Cluster.AddFlags(fs)
}