kube
kube copied to clipboard
Label selector & Field selector syntax evaluation
Would you like to work on this feature?
Sure!
What problem are you trying to solve?
Let's say I have an application using Api<K>::list
with some ListParams { label_selector: Some(_), field_selector: Some(_), _}
to filter results. If I then want to maintain a cache runtime::reflector::Store<K>
and call Store<K>::state
, I'd like to be able to filter the Vec<Arc<K>>
based on ListParams
.
For example: if I have a Store<Pod>
of all pods all namespaces, I'd like to lookup store.state()
with multiple different label_selector
expressions, without having to keep multiple Store<Pod>
s around.
Describe the solution you'd like
I'd like to evaluate selector syntax and filter a Vec<AsRef<K>>
based on some ListParams
. I'm not sure if this is planned or within the scope of this crate.
Describe alternatives you've considered
Alternate solutions require more restrictive API designs when using Store<K>
on applications with dynamic-list requirements.
Documentation, Adoption, Migration Strategy
No response
Target crate for feature
kube-core
oh, that is interesting, basically runtime simulation of what the apiserver does with ListParams
I think this type of thing can probably be added direct as pub
impls on Store
now that we are using a less difficult datastore (AHashMap rather than the lockfree one) and I have also wanted some extra convenience helpers there so +1 for something like this.
Not sure I would want it to take the whole of ListParams
as an input though, since most params there don't make sense for local filtering (like timeouts, bookmarks and continue tokens), but label filtration makes sense. Maybe it would make sense to do some more general filter lambdas like AsRef<K> -> bool
since they should be able to be inlined rather easily?