-
Notifications
You must be signed in to change notification settings - Fork 37
/
options.go
67 lines (60 loc) · 2.78 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
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2021 Terminus, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package options
import (
"github.com/spf13/pflag"
)
type ProbeMasterOptions struct {
MetricsAddr string
PprofAddr string
HealthProbeAddr string
EnableLeaderElection bool
EnablePprof bool
LeaderElectionNamespace string
Namespace string
CreateDefaultPool bool
Version bool
ProbeMasterListenAddr string
}
// NewProbeMasterOptions creates a new NewProbeMasterOptions with a default config.
func NewProbeMasterOptions() *ProbeMasterOptions {
o := &ProbeMasterOptions{
MetricsAddr: ":8081",
PprofAddr: ":8091",
HealthProbeAddr: ":8001",
EnableLeaderElection: false,
EnablePprof: false,
LeaderElectionNamespace: "kube-system",
Namespace: "",
CreateDefaultPool: false,
ProbeMasterListenAddr: ":8088",
}
return o
}
// ValidateOptions validates YurtAppOptions
func ValidateOptions(options *ProbeMasterOptions) error {
// TODO
return nil
}
// AddFlags returns flags for a specific yurthub by section name
func (o *ProbeMasterOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.MetricsAddr, "metrics-addr", o.MetricsAddr, "The address the metric endpoint binds to.")
fs.StringVar(&o.PprofAddr, "pprof-addr", o.PprofAddr, "The address the pprof binds to.")
fs.StringVar(&o.HealthProbeAddr, "health-probe-addr", o.HealthProbeAddr, "The address the healthz/readyz endpoint binds to.")
fs.BoolVar(&o.EnableLeaderElection, "enable-leader-election", o.EnableLeaderElection, "Whether you need to enable leader election.")
fs.BoolVar(&o.EnablePprof, "enable-pprof", o.EnablePprof, "Enable pprof for controller manager.")
fs.StringVar(&o.LeaderElectionNamespace, "leader-election-namespace", o.LeaderElectionNamespace, "This determines the namespace in which the leader election configmap will be created, it will use in-cluster namespace if empty.")
fs.StringVar(&o.Namespace, "namespace", o.Namespace, "Namespace if specified restricts the manager's cache to watch objects in the desired namespace. Defaults to all namespaces.")
fs.BoolVar(&o.CreateDefaultPool, "create-default-pool", o.CreateDefaultPool, "Create default cloud/edge pools if indicated.")
fs.BoolVar(&o.Version, "version", o.Version, "print the version information.")
}