@@ -19,7 +19,6 @@ package options
1919import (
2020 "os"
2121 "sync"
22- "time"
2322
2423 "github.com/spf13/pflag"
2524 corev1 "k8s.io/api/core/v1"
@@ -38,23 +37,34 @@ func getFromEnvOrDefault(key, def string) string {
3837
3938// Options is the data structure that contains information about mysql operator configuration
4039type Options struct {
40+ // SidecarImage is the image used in sidecar container to serve backups and configure MySQL
4141 SidecarImage string
4242
43+ // MetricsExporterImage is the image for exporter container
4344 MetricsExporterImage string
4445
46+ // ImagePullSecretName is the secret name where are found secrets for pulling images. This is
47+ // the default value and may be overwrite by the cluster .spec.podSpec.imagePullSecrets field.
4548 ImagePullSecretName string
46- ImagePullPolicy corev1.PullPolicy
49+ // ImagePullPolicy is the default image pull policy
50+ ImagePullPolicy corev1.PullPolicy
4751
48- OrchestratorURI string
52+ // OrchestratorURI represents the URI where the Orchestrator can be reached.
53+ OrchestratorURI string
54+ // OrchestratorTopologyPassword is the password that is used by Orchestrator to connect to MySQL
55+ // nodes. This field is set in cluster secret as well.
4956 OrchestratorTopologyPassword string
50- OrchestratorTopologyUser string
51-
52- JobCompleteSuccessGraceTime time.Duration
53-
54- HTTPServeAddr string
57+ // OrchestratorTopologyUser is the user that is used by Orchestrator to connect to MySQL
58+ // nodes. This field is set in cluster secret as well.
59+ OrchestratorTopologyUser string
5560
61+ // LeaderElectionNamespace the namespace where the lock resource will be created
5662 LeaderElectionNamespace string
57- LeaderElectionID string
63+ // LederElectionID the name of the lock resource
64+ LeaderElectionID string
65+
66+ // Namespace where to look after objects. This will limit the operator action range.
67+ Namespace string
5868}
5969
6070type pullpolicy corev1.PullPolicy
@@ -81,20 +91,20 @@ func newPullPolicyValue(defaultValue corev1.PullPolicy, v *corev1.PullPolicy) *p
8191const (
8292 defaultExporterImage = "prom/mysqld-exporter:latest"
8393
84- defaultImagePullPolicy = corev1 .PullIfNotPresent
94+ defaultImagePullPolicy = corev1 .PullIfNotPresent
95+ defaultImagePullSecretName = ""
8596
8697 defaultOrchestratorTopologyUser = ""
8798 defaultOrchestratorTopologyPassword = ""
8899
89- defaultHTTPServerAddr = ":80"
90-
91100 defaultLeaderElectionNamespace = "default"
92101 defaultLeaderElectionID = ""
102+
103+ defaultNamespace = ""
93104)
94105
95106var (
96107 defaultSidecarImage = "quay.io/presslabs/mysql-operator-sidecar:" + util .AppVersion
97- defaultJobGraceTime = 24 * time .Hour
98108)
99109
100110// AddFlags registers all mysql-operator needed flags
@@ -104,7 +114,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
104114
105115 fs .StringVar (& o .MetricsExporterImage , "metrics-exporter-image" , defaultExporterImage ,
106116 "The image for mysql metrics exporter." )
107- fs .StringVar (& o .ImagePullSecretName , "image-pull-secret" , "" ,
117+ fs .StringVar (& o .ImagePullSecretName , "image-pull-secret" , defaultImagePullSecretName ,
108118 "The secret name for used as pull secret." )
109119
110120 fs .VarP (newPullPolicyValue (defaultImagePullPolicy , & o .ImagePullPolicy ),
@@ -116,16 +126,14 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
116126 "The orchestrator topology password. Can also be set as ORC_TOPOLOGY_PASSWORD environment variable." )
117127 fs .StringVar (& o .OrchestratorTopologyUser , "orchestrator-topology-user" , defaultOrchestratorTopologyPassword ,
118128 "The orchestrator topology user. Can also be set as ORC_TOPOLOGY_USER environment variable." )
119- fs .DurationVar (& o .JobCompleteSuccessGraceTime , "job-grace-time" , defaultJobGraceTime ,
120- "The time in hours how jobs after completion are keept." )
121-
122- fs .StringVar (& o .HTTPServeAddr , "http-serve-addr" , defaultHTTPServerAddr ,
123- "The address for http server." )
124129
125130 fs .StringVar (& o .LeaderElectionNamespace , "leader-election-namespace" , defaultLeaderElectionNamespace ,
126131 "The leader election namespace." )
127132 fs .StringVar (& o .LeaderElectionID , "leader-election-id" , defaultLeaderElectionID ,
128133 "The leader election id." )
134+
135+ fs .StringVar (& o .Namespace , "namespace" , defaultNamespace ,
136+ "The namespace to restrict the client to watch objects." )
129137}
130138
131139var instance * Options
@@ -138,13 +146,13 @@ func GetOptions() *Options {
138146 SidecarImage : defaultSidecarImage ,
139147 MetricsExporterImage : defaultExporterImage ,
140148
141- ImagePullPolicy : defaultImagePullPolicy ,
142- JobCompleteSuccessGraceTime : defaultJobGraceTime ,
149+ ImagePullPolicy : defaultImagePullPolicy ,
150+ ImagePullSecretName : defaultImagePullSecretName ,
143151
144- OrchestratorTopologyUser : "" ,
145- OrchestratorTopologyPassword : "" ,
152+ OrchestratorTopologyUser : defaultOrchestratorTopologyUser ,
153+ OrchestratorTopologyPassword : defaultOrchestratorTopologyPassword ,
146154
147- HTTPServeAddr : defaultHTTPServerAddr ,
155+ Namespace : defaultNamespace ,
148156 }
149157 })
150158
0 commit comments