@@ -211,7 +211,7 @@ func main() {
211211 c .NextProtos = []string {"http/1.1" }
212212 }
213213
214- if ! cfg .Static . EnableHTTP2 {
214+ if ! cfg .EnableHTTP2 () {
215215 tlsOpts = append (tlsOpts , disableHTTP2 )
216216 }
217217
@@ -221,16 +221,16 @@ func main() {
221221 // Initial webhook TLS options
222222 webhookTLSOpts := tlsOpts
223223
224- if len (cfg .Static . WebhookCertPath ) > 0 {
224+ if len (cfg .WebhookCertPath () ) > 0 {
225225 setupLog .Info ("Initializing webhook certificate watcher using provided certificates" ,
226- "webhookCertPath" , cfg .Static . WebhookCertPath ,
227- "webhookCertName" , cfg .Static . WebhookCertName ,
228- "webhookCertKey" , cfg .Static . WebhookCertKey )
226+ "webhookCertPath" , cfg .WebhookCertPath () ,
227+ "webhookCertName" , cfg .WebhookCertName () ,
228+ "webhookCertKey" , cfg .WebhookCertKey () )
229229
230230 var err error
231231 webhookCertWatcher , err = certwatcher .New (
232- filepath .Join (cfg .Static . WebhookCertPath , cfg .Static . WebhookCertName ),
233- filepath .Join (cfg .Static . WebhookCertPath , cfg .Static . WebhookCertKey ),
232+ filepath .Join (cfg .WebhookCertPath () , cfg .WebhookCertName () ),
233+ filepath .Join (cfg .WebhookCertPath () , cfg .WebhookCertKey () ),
234234 )
235235 if err != nil {
236236 setupLog .Error (err , "Failed to initialize webhook certificate watcher" )
@@ -251,12 +251,12 @@ func main() {
251251 // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.4/pkg/metrics/server
252252 // - https://book.kubebuilder.io/reference/metrics.html
253253 metricsServerOptions := metricsserver.Options {
254- BindAddress : cfg .Static . MetricsAddr ,
255- SecureServing : cfg .Static . SecureMetrics ,
254+ BindAddress : cfg .MetricsAddr () ,
255+ SecureServing : cfg .SecureMetrics () ,
256256 TLSOpts : tlsOpts ,
257257 }
258258
259- if cfg .Static . SecureMetrics {
259+ if cfg .SecureMetrics () {
260260 // FilterProvider is used to protect the metrics endpoint with authn/authz.
261261 // These configurations ensure that only authorized users and service accounts
262262 // can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info:
@@ -272,17 +272,17 @@ func main() {
272272 // - [METRICS-WITH-CERTS] at config/default/kustomization.yaml to generate and use certificates
273273 // managed by cert-manager for the metrics server.
274274 // - [PROMETHEUS-WITH-CERTS] at config/prometheus/kustomization.yaml for TLS certification.
275- if len (cfg .Static . MetricsCertPath ) > 0 {
275+ if len (cfg .MetricsCertPath () ) > 0 {
276276 setupLog .Info ("Initializing metrics certificate watcher using provided certificates" ,
277- "metricsCertPath" , cfg .Static . MetricsCertPath ,
278- "metricsCertName" , cfg .Static . MetricsCertName ,
279- "metricsCertKey" , cfg .Static . MetricsCertKey ,
277+ "metricsCertPath" , cfg .MetricsCertPath () ,
278+ "metricsCertName" , cfg .MetricsCertName () ,
279+ "metricsCertKey" , cfg .MetricsCertKey () ,
280280 )
281281
282282 var err error
283283 metricsCertWatcher , err = certwatcher .New (
284- filepath .Join (cfg .Static . MetricsCertPath , cfg .Static . MetricsCertName ),
285- filepath .Join (cfg .Static . MetricsCertPath , cfg .Static . MetricsCertKey ),
284+ filepath .Join (cfg .MetricsCertPath () , cfg .MetricsCertName () ),
285+ filepath .Join (cfg .MetricsCertPath () , cfg .MetricsCertKey () ),
286286 )
287287 if err != nil {
288288 setupLog .Error (err , "Failed to initialize metrics certificate watcher" )
@@ -298,25 +298,28 @@ func main() {
298298 ds := datastore .NewDatastore (cfg )
299299
300300 // Use configurable REST client timeout from Config (default 60s, can be overridden via --rest-client-timeout flag)
301- restConfig .Timeout = cfg .Static . RestTimeout
301+ restConfig .Timeout = cfg .RestTimeout ()
302302
303303 // Configure leader election with configurable timeouts to prevent lease renewal failures
304304 // Default values are: LeaseDuration=60s, RenewDeadline=50s, RetryPeriod=10s
305305 // These can be overridden via command-line flags in manager.yaml
306306 // Increased from controller-runtime defaults (15s, 10s, 2s) to provide more tolerance
307307 // for network latency and API server delays
308308
309+ leaseDurationVal := cfg .LeaseDuration ()
310+ renewDeadlineVal := cfg .RenewDeadline ()
311+ retryPeriodVal := cfg .RetryPeriod ()
309312 mgrOptions := ctrl.Options {
310313 Scheme : scheme ,
311314 Metrics : metricsServerOptions ,
312315 WebhookServer : webhookServer ,
313- HealthProbeBindAddress : cfg .Static . ProbeAddr ,
314- LeaderElection : cfg .Static . EnableLeaderElection ,
315- LeaderElectionID : cfg .Static . LeaderElectionID ,
316+ HealthProbeBindAddress : cfg .ProbeAddr () ,
317+ LeaderElection : cfg .EnableLeaderElection () ,
318+ LeaderElectionID : cfg .LeaderElectionID () ,
316319 // Leader election timeout configuration (from Config, can be overridden via flags/env/ConfigMap)
317- LeaseDuration : & cfg . Static . LeaseDuration ,
318- RenewDeadline : & cfg . Static . RenewDeadline ,
319- RetryPeriod : & cfg . Static . RetryPeriod ,
320+ LeaseDuration : & leaseDurationVal ,
321+ RenewDeadline : & renewDeadlineVal ,
322+ RetryPeriod : & retryPeriodVal ,
320323 // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
321324 // when the Manager ends. This requires the binary to immediately end when the
322325 // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
@@ -329,11 +332,12 @@ func main() {
329332 LeaderElectionReleaseOnCancel : true ,
330333 }
331334
332- if cfg .Static .WatchNamespace != "" {
333- setupLog .Info ("Watching single namespace" , "namespace" , cfg .Static .WatchNamespace )
335+ watchNS := cfg .WatchNamespace ()
336+ if watchNS != "" {
337+ setupLog .Info ("Watching single namespace" , "namespace" , watchNS )
334338 mgrOptions .Cache = cache.Options {
335339 DefaultNamespaces : map [string ]cache.Config {
336- cfg . Static . WatchNamespace : {},
340+ watchNS : {},
337341 },
338342 }
339343 }
@@ -351,8 +355,8 @@ func main() {
351355 setupLog .Info ("Metrics emitter created successfully" )
352356
353357 // Use Prometheus configuration from unified Config (already validated during Load())
354- promConfig := cfg .Static . Prometheus
355- if promConfig == nil {
358+ promConfig := cfg .Prometheus ()
359+ if promConfig == nil || promConfig . BaseURL == "" {
356360 setupLog .Error (nil , "no Prometheus configuration found - this should not happen after validation" )
357361 os .Exit (1 )
358362 }
@@ -440,12 +444,13 @@ func main() {
440444 os .Exit (1 )
441445 }
442446
443- // Create the reconciler with unified Config
447+ // Create the reconciler with unified Config and datastore
444448 reconciler := & controller.VariantAutoscalingReconciler {
445- Client : mgr .GetClient (),
446- Scheme : mgr .GetScheme (),
447- Recorder : mgr .GetEventRecorderFor ("workload-variant-autoscaler-controller-manager" ),
448- Config : cfg , // Pass unified Config to reconciler
449+ Client : mgr .GetClient (),
450+ Scheme : mgr .GetScheme (),
451+ Recorder : mgr .GetEventRecorderFor ("workload-variant-autoscaler-controller-manager" ),
452+ Config : cfg , // Pass unified Config to reconciler
453+ Datastore : ds , // Pass datastore for namespace tracking
449454 }
450455
451456 // Setup the controller with the manager
0 commit comments