-
Notifications
You must be signed in to change notification settings - Fork 60
/
options.go
44 lines (34 loc) · 1.3 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
package options
import (
"fmt"
"github.com/spf13/pflag"
)
type ControllerOptions struct {
KubernetesAPIQPS float32
KubernetesAPIBurst int
DisableApprovedCheck bool
}
const (
defaultKubernetesAPIQPS float32 = 20
defaultKubernetesAPIBurst int = 50
)
func NewControllerOptions() *ControllerOptions {
return &ControllerOptions{
KubernetesAPIQPS: defaultKubernetesAPIQPS,
KubernetesAPIBurst: defaultKubernetesAPIBurst,
}
}
func (o *ControllerOptions) AddFlags(fs *pflag.FlagSet) {
fs.Float32Var(&o.KubernetesAPIQPS, "kube-api-qps", defaultKubernetesAPIQPS, "Maximium queries-per-second of requests to the Kubernetes apiserver.")
fs.IntVar(&o.KubernetesAPIBurst, "kube-api-burst", defaultKubernetesAPIBurst, "Maximium queries-per-second burst of request send to the Kubernetes apiserver.")
fs.BoolVar(&o.DisableApprovedCheck, "disable-approved-check", o.DisableApprovedCheck, "Disables waiting for CertificateRequests to have an approved condition before signing.")
}
func (o *ControllerOptions) Validate() error {
if o.KubernetesAPIBurst <= 0 {
return fmt.Errorf("invalid value for kube-api-burst: %v must be higher than 0", o.KubernetesAPIBurst)
}
if o.KubernetesAPIQPS <= 0 {
return fmt.Errorf("invalid value for kube-api-qps: %v must be higher than 0", o.KubernetesAPIQPS)
}
return nil
}