Skip to content

Commit

Permalink
de-duplicate config initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
MatousJobanek committed Mar 7, 2025
1 parent 96f6044 commit 6df08c0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ func main() {
}
crtConfig.Print()

discoveryClient, err := discovery.NewDiscoveryClientForConfig(ctrl.GetConfigOrDie())
discoveryClient, err := discovery.NewDiscoveryClientForConfig(cfg)
if err != nil {
setupLog.Error(err, "failed to create discovery client")
os.Exit(1)
}

// Webhook server will be created with default values (port 9443) as per doc - https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/manager/manager.go#L244-L247
// Cache Options design doc - https://github.com/kubernetes-sigs/controller-runtime/blob/main/designs/cache_options.md
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
Expand All @@ -188,7 +188,7 @@ func main() {
// This client should be used only for resources and kinds that are retrieved from other namespaces than the watched one.
// This will help keeping a reasonable memory usage for this operator since the cache won't store all other namespace scoped
// resources (secrets, etc.).
allNamespacesCluster, err := runtimecluster.New(ctrl.GetConfigOrDie(), func(options *runtimecluster.Options) {
allNamespacesCluster, err := runtimecluster.New(cfg, func(options *runtimecluster.Options) {
options.Scheme = scheme
})
if err != nil {
Expand Down

0 comments on commit 6df08c0

Please sign in to comment.