-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
55 lines (45 loc) · 1.93 KB
/
options.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
package options
import (
"time"
"github.com/spf13/pflag"
"github.com/anywhy/redis-operator/pkg/controller"
)
// RedisControllerManagerOptions redis controller options
type RedisControllerManagerOptions struct {
Master string
Kubeconfig string
Namespace string
// PrintVersion bool
Workers int
AutoFailover bool
// ConfigFile is the location of the scheduler server's configuration file.
ConfigFile string
LeaseDuration time.Duration
RenewDuration time.Duration
RetryPeriod time.Duration
ResyncDuration time.Duration
WaitDuration time.Duration
}
// NewRedisControllerManagerOptions new default redis options
func NewRedisControllerManagerOptions() *RedisControllerManagerOptions {
return &RedisControllerManagerOptions{
Workers: 2,
LeaseDuration: 15 * time.Second,
RenewDuration: 5 * time.Second,
RetryPeriod: 3 * time.Second,
ResyncDuration: 30 * time.Second,
WaitDuration: 5 * time.Second,
}
}
// AddFlags add operator options flags
func (s *RedisControllerManagerOptions) AddFlags(pflag *pflag.FlagSet) {
pflag.StringVar(&s.Master, "master", s.Master, "k8s master addr")
pflag.StringVar(&s.ConfigFile, "config", s.ConfigFile, "The path to the configuration file. Flags override values in this file.")
// pflag.BoolVar(&s.PrintVersion, "version", false, "Show version and quit")
pflag.BoolVar(&s.AutoFailover, "auto-failover", true, "Replica cluster auto failover")
pflag.StringVar(&s.Namespace, "namespace", s.Namespace, "The Operator deployment of k8s namespce")
pflag.BoolVar(&controller.ClusterScoped, "cluster-scoped", true, "Whether redis-operator should manage kubernetes cluster wide Redis Clusters")
pflag.StringVar(&s.Kubeconfig, "kubeconfig", "", "Config k8s config file path")
pflag.IntVar(&s.Workers, "workers", s.Workers, "start by threads number for worker")
pflag.StringVar(&controller.DefaultStorageClassName, "default-storage-class-name", "standard", "Default storage class name")
}