Skip to content

Commit

Permalink
handler: refactor Manager's cache options
Browse files Browse the repository at this point in the history
In kubernetes-sigs/controller-runtime#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 <mko@redhat.com>
  • Loading branch information
mkowalski committed Oct 19, 2023
1 parent d40edc0 commit 1855f30
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/handler/main.go
Expand Up @@ -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,
},
Expand All @@ -184,7 +185,7 @@ func cacheResourcesOnNodes(ctrlOptions *ctrl.Options) {
Label: nodeLabelMatchingNodeNameSelector,
},
},
})
}
}

func setupHandlerControllers(mgr manager.Manager) error {
Expand Down

0 comments on commit 1855f30

Please sign in to comment.