-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constrain Resource trait and Api::namespaced by Scope #956
Conversation
To prevent the namespace type errors we've been seeing for ages that we have the tools to prevent. Early sketch. Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #956 +/- ##
==========================================
+ Coverage 72.46% 72.50% +0.04%
==========================================
Files 64 64
Lines 4412 4426 +14
==========================================
+ Hits 3197 3209 +12
- Misses 1215 1217 +2
|
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Peripheral fix to cargo deny included (license case that as best i can tell does not apply to us - dtolnay/unicode-ident#9 - stole the wording from a similar pr in automerge/automerge#409). Can cherry pick to another branch if desired. |
Signed-off-by: clux <[email protected]>
Yeah, this will be rough if we change
I think
|
A bit torn on this, because while it might be slightly confusing semantically, there's no real penalty for having the If we deprecate and introduce a longer named variant of the same thing, then I kind of think that is worse, because we force people to do the same migration anyway (just through warnings in their own time), and i don't think we actually need to do this: The remaining error case (accidentally querying across too many namespaces) does not feel severe enough to warrant a migration. The most confusing user error is caught by constricting Long term though; I am getting more and more inclined to making query methods onto |
Yeah, I was just thinking of a way if we decide to add This is useful already. Other changes are probably not worth doing, and definitely not a blocker for this. |
Signed-off-by: clux <[email protected]>
I was pretty late on this, but...
Yeah, this is how we do it at @stackabletech (we have our own |
Yeah, I can see it having ergonomic improvement in many places. I also don't think we need to break the |
As an example - https://docs.rs/kube-client-ext/latest/kube_client_ext/trait.KubeClientExt.html |
To prevent the namespace type errors users run into occassionally (like #952 ), and fixes #194 . k8s-openapi added these a year back but didn't have time to make everything work back then.
Resource
withScope
associated typeDynamicScope
as animpl ResourceScope
for dynamic/unstructured objs#[kube(namespaced)]
to decide scope forkube-derive
compile_fail
on negative caseNote the extra inlined bodies of
Api::*namespaced
methods now cannot call each other because the_with
suffixed ones have a signature for dynamic scoped ones only.The scope type is directly the
ResourceScope
trait fromk8s-openapi
. Long term maybe we can get this into a traits crate if we can get consensus, but afaikt it's not possible to have our own trait for this unless it's the same one used downstream. It's not a big deal now, but will be annoying in k8s-pb.One thing we could do is to add an
Api::cluster
ctor with an explicitClusterScope
constraint. This might be good, but it leavesApi::all
in a bad state. Do we put aNamespaceScope
constraint onApi::all
after years of users using it for cluster stuff? The migration path is horrible. I found it annoying to even do internally in kube; 8613992, and dynamic types struggle even more with it. Have opted not to do it for now. There are ultimately no user consequences / benefits in distinguishing cluster resources from all namespaces other than the slight semantic improvement.