You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: main.go
+85-79Lines changed: 85 additions & 79 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ limitations under the License.
18
18
package main
19
19
20
20
import (
21
+
"context"
21
22
"flag"
22
23
"fmt"
23
24
"os"
@@ -56,14 +57,16 @@ var (
56
57
healthAddrstring
57
58
syncPeriod time.Duration
58
59
diagnosticsOptions= flags.DiagnosticsOptions{}
60
+
webhookPortint
61
+
webhookCertDirstring
59
62
60
-
scheme=runtime.NewScheme()
61
-
setupLog=ctrl.Log.WithName("setup")
62
-
webhookPortint
63
-
webhookCertDirstring
63
+
scheme=runtime.NewScheme()
64
+
setupLog=ctrl.Log.WithName("setup")
64
65
)
65
66
66
67
funcinit() {
68
+
klog.InitFlags(nil)
69
+
67
70
_=clientgoscheme.AddToScheme(scheme)
68
71
69
72
_=infrav1beta1.AddToScheme(scheme)
@@ -72,13 +75,79 @@ func init() {
72
75
// +kubebuilder:scaffold:scheme
73
76
}
74
77
78
+
funcinitFlags(fs*pflag.FlagSet) {
79
+
fs.BoolVar(
80
+
&enableLeaderElection,
81
+
"leader-elect",
82
+
false,
83
+
"Enable leader election for controller manager. "+
84
+
"Enabling this will ensure there is only one active controller manager.",
85
+
)
86
+
87
+
fs.StringVar(
88
+
&watchNamespace,
89
+
"namespace",
90
+
"",
91
+
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.",
92
+
)
93
+
94
+
fs.StringVar(
95
+
&healthAddr,
96
+
"health-addr",
97
+
":9440",
98
+
"The address the health endpoint binds to.",
99
+
)
100
+
101
+
fs.DurationVar(
102
+
&syncPeriod,
103
+
"sync-period",
104
+
10*time.Minute,
105
+
"The minimum interval at which watched resources are reconciled.",
106
+
)
107
+
108
+
fs.StringVar(
109
+
&options.ProviderIDFormat,
110
+
"provider-id-fmt",
111
+
string(options.ProviderIDFormatV1),
112
+
"ProviderID format is used set the Provider ID format for Machine",
113
+
)
114
+
115
+
fs.StringVar(
116
+
&endpoints.ServiceEndpointFormat,
117
+
"service-endpoint",
118
+
"",
119
+
"Set custom service endpoint in semi-colon separated format: ${ServiceRegion1}:${ServiceID1}=${URL1},${ServiceID2}=${URL2};${ServiceRegion2}:${ServiceID1}=${URL1}",
120
+
)
121
+
122
+
fs.IntVar(&webhookPort,
123
+
"webhook-port",
124
+
9443,
125
+
"The webhook server port the manager will listen on.",
setupLog.Info("Using v1 version of ProviderID format")
138
+
caseoptions.ProviderIDFormatV2:
139
+
setupLog.Info("Using v2 version of ProviderID format")
140
+
default:
141
+
returnfmt.Errorf("invalid value for flag provider-id-fmt: %s, Supported values: %s, %s ", options.ProviderIDFormat, options.ProviderIDFormatV1, options.ProviderIDFormatV2)
142
+
}
143
+
returnnil
144
+
}
145
+
75
146
// Add RBAC for the authorized diagnostics endpoint.
"Enable leader election for controller manager. "+
168
-
"Enabling this will ensure there is only one active controller manager.",
169
-
)
170
-
171
-
fs.StringVar(
172
-
&watchNamespace,
173
-
"namespace",
174
-
"",
175
-
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.",
176
-
)
177
-
178
-
fs.StringVar(
179
-
&healthAddr,
180
-
"health-addr",
181
-
":9440",
182
-
"The address the health endpoint binds to.",
183
-
)
184
-
185
-
fs.DurationVar(
186
-
&syncPeriod,
187
-
"sync-period",
188
-
10*time.Minute,
189
-
"The minimum interval at which watched resources are reconciled.",
190
-
)
191
-
192
-
fs.StringVar(
193
-
&options.ProviderIDFormat,
194
-
"provider-id-fmt",
195
-
string(options.ProviderIDFormatV1),
196
-
"ProviderID format is used set the Provider ID format for Machine",
197
-
)
198
-
199
-
fs.StringVar(
200
-
&endpoints.ServiceEndpointFormat,
201
-
"service-endpoint",
202
-
"",
203
-
"Set custom service endpoint in semi-colon separated format: ${ServiceRegion1}:${ServiceID1}=${URL1},${ServiceID2}=${URL2};${ServiceRegion2}:${ServiceID1}=${URL1}",
204
-
)
205
-
206
-
fs.IntVar(&webhookPort,
207
-
"webhook-port",
208
-
9443,
209
-
"The webhook server port the manager will listen on.",
setupLog.Info("Using v1 version of ProviderID format")
222
-
caseoptions.ProviderIDFormatV2:
223
-
setupLog.Info("Using v2 version of ProviderID format")
224
-
default:
225
-
returnfmt.Errorf("invalid value for flag provider-id-fmt: %s, Supported values: %s, %s ", options.ProviderIDFormat, options.ProviderIDFormatV1, options.ProviderIDFormatV2)
0 commit comments