From d461b83296f660e4f786f9c899f7379e5f502074 Mon Sep 17 00:00:00 2001 From: Mat Kowalski Date: Thu, 19 Oct 2023 15:31:45 +0200 Subject: [PATCH] handler: refactor Manager's cache options In https://github.com/kubernetes-sigs/controller-runtime/pull/2300 the `cache.BuilderWithOptions` has been deprecated in favour of cache options embeded in the Manager. This PR rewrites our custom cache configuration to use the new way of configuring it via those new options. Signed-off-by: Mat Kowalski --- cmd/handler/main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/handler/main.go b/cmd/handler/main.go index 15af75421..5fcdb82d1 100644 --- a/cmd/handler/main.go +++ b/cmd/handler/main.go @@ -172,8 +172,9 @@ func cacheResourcesOnNodes(ctrlOptions *ctrl.Options) { nodeName := environment.NodeName() metadataNameMatchingNodeNameSelector := fields.Set{"metadata.name": nodeName}.AsSelector() nodeLabelMatchingNodeNameSelector := labels.Set{nmstateapi.EnactmentNodeLabel: nodeName}.AsSelector() - ctrlOptions.NewCache = cache.BuilderWithOptions(cache.Options{ - SelectorsByObject: cache.SelectorsByObject{ + + ctrlOptions.Cache = cache.Options{ + ByObject: map[client.Object]cache.ByObject{ &corev1.Node{}: { Field: metadataNameMatchingNodeNameSelector, }, @@ -184,7 +185,7 @@ func cacheResourcesOnNodes(ctrlOptions *ctrl.Options) { Label: nodeLabelMatchingNodeNameSelector, }, }, - }) + } } func setupHandlerControllers(mgr manager.Manager) error {