Open floreks opened 2 months ago
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: floreks Once this PR has been reviewed and has the lgtm label, please assign mortent for approval. For more information see the Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
What's the benefit of using a custom object filter?
The built-in filter filters by ID from a map, so it's pretty efficient, just a hashtable lookup. It shouldn't cause any real performance impact.
There might not be many use cases for the custom implementation of ObjectFilter
. Being able to disable it completely when relying on server-side filtering is what I was looking for. If that would be something you would be interested in, let me know and I will adjust the code.
PS. From what I can see current AllowListObjectFilter
is simply going through the array and doing a struct comparison.
https://github.com/kubernetes-sigs/cli-utils/blob/4d57e6e23edac29f2ea3ae9aa8b0ff0a85fc01cc/pkg/kstatus/watcher/object_filter.go#L27-L30
https://github.com/kubernetes-sigs/cli-utils/blob/4d57e6e23edac29f2ea3ae9aa8b0ff0a85fc01cc/pkg/object/objmetadata_set.go#L56-L62
With the addition of
Filters
to theDefaultStatusWatcher
it is now possible to apply server-side filtering via labels/fields. This PR allows dropping or overriding client-side filtering with a customObjectFilter
. In our case we are making sure that every resource in the inventory will contain a static label that can be used for server-side filtering and further client-side filtering is obsolete.