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 20, 2023
1 parent 78b7268 commit d461b83
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 d461b83

Please sign in to comment.