Conversation
Signed-off-by: clux <sszynrae@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1313 +/- ##
=======================================
- Coverage 72.4% 72.4% -0.0%
=======================================
Files 75 75
Lines 6343 6357 +14
=======================================
+ Hits 4587 4597 +10
- Misses 1756 1760 +4
🚀 New features to boost your workflow:
|
Signed-off-by: clux <sszynrae@gmail.com>
|
I think there isn't much gain in limiting all to It would be different if we would also track as a second generic how the |
|
While I am not attached to this particular design, I think it's important to keep in mind that this code setup might not help Sure, the generic code case was never easy, but I don't think a setup like this would make it significantly harder - particularly if they have written all the cases you linked. It's also a minority of people that needs to write that code. It's generic code. The number of people encountering the pain needs to be considered. As a side-note, I almost feel like those particular generic api getters are done at the wrong level. That code is setup to expose an interface for a namespace on something that doesn't have a namespace. This means you no longer know by type whether it's safe to unwrap the To illustrate some ways you can do generics (because I ended up thinking about this a bit this week), there's a new PR at kube-rs/website#47 to show some ways to get around some of these issues in easier ways. |
|
As an extra point, I do think there are two orthogonal use-cases for
It is possible we need to follow a style a bit more like client-go and have a ListWatcher style entrypoint for watcher. |
Proof of Concept
Wanted to see how this ended up looking. I am not 100% convinced about this yet.
Motivation
Currently the biggest footgun in kube right now is
Api::alland its interaction with Namespaced objects.An
Api::allon aResource = NamespacedResourceis an extremely stunted implementation that only really allowsApi::list,Api::watch.All the other Api methods will fail with 404s because it by construction creates invalid request urls.
Main issues:
getwithApi::all()response can't be 404 #1276Api::allfails to create namespaced resources #1030and a couple from discussions:
finalizerProposal
Api::allApi::allunless they actually want a cross-namespace listerThis does mean one breaking change:
Api::allnow requiresNamespaceResourceScope+ put a big warning on it that it's only for listwatching.and add two new main
Apiconstructors to compensate:Api::cluster- limited toClusterResourceScopeApi::dynamic- limited toDynamicResourceScopea potential setup for api construction from discovery to show this does not make it worse
Alternatives
NamespaceResourceScopescope constraint onApi::allfor a non-breaking change.Apino matter what, so thought we may as well make this as good as possibleDrawbacks