func BuildRuntimeOptions()

in pkg/config/runtime_config.go [111:128]


func BuildRuntimeOptions(rtCfg RuntimeConfig, scheme *runtime.Scheme) ctrl.Options {
	cacheOptions := BuildCacheOptions()
	// if WatchNamespace in Options is not set, cache will watch for all namespaces
	if rtCfg.WatchNamespace != corev1.NamespaceAll {
		cacheOptions.DefaultNamespaces = map[string]cache.Config{
			rtCfg.WatchNamespace: {},
		}
	}
	return ctrl.Options{
		Scheme:                  scheme,
		Metrics:                 metricsserver.Options{BindAddress: rtCfg.MetricsBindAddress},
		HealthProbeBindAddress:  rtCfg.HealthProbeBindAddress,
		LeaderElection:          rtCfg.EnableLeaderElection,
		LeaderElectionID:        rtCfg.LeaderElectionID,
		LeaderElectionNamespace: rtCfg.LeaderElectionNamespace,
		Cache:                   cacheOptions,
	}
}