Merge ErrorResponse and Status#1875
Conversation
ec14000 to
b56df67
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1875 +/- ##
=======================================
+ Coverage 75.9% 76.0% +0.2%
=======================================
Files 85 85
Lines 8237 8267 +30
=======================================
+ Hits 6244 6276 +32
+ Misses 1993 1991 -2
🚀 New features to boost your workflow:
|
b56df67 to
e41d35d
Compare
clux
left a comment
There was a problem hiding this comment.
Thanks a lot. I like this approach personally. Left some questions initially and my thoughts on enums/const strs here (tl;dr; i don't think it's worth making it more advanced, but we should document where we got the values from).
|
So the question now is what to do with the original I can think of three options:
Dropping it may be too drastic, type alias - I personally not a fan of it. My choice would be deprecating and removing in one of the followup releases. Any feedback on that ? |
You could do this, and it would slightly help users who use the struct directly in unexpected ways, but it wouldn't help the
This would cause a small extra break for the users actually making an If people have to change the |
Agree. I'll make necessary changes. |
5d94bb1 to
bab55b0
Compare
|
Sorry, I accidentally clicked the "Update branch" button and created a merge commit (2910383). If you prefer a clean rebase history, please feel free to force push to remove this merge commit. Apologies for the noise! |
No worries |
2910383 to
36ad35c
Compare
clux
left a comment
There was a problem hiding this comment.
Looks great. Thank you.
clippy is red, but that's because you pushed literally a minute before it got fixed so nw :D
happy to merge if you are
Signed-off-by: Cyril Plisko <[email protected]>
Signed-off-by: Cyril Plisko <[email protected]>
Signed-off-by: Cyril Plisko <[email protected]>
Signed-off-by: Cyril Plisko <[email protected]>
Signed-off-by: Cyril Plisko <[email protected]>
36ad35c to
4dd3ce9
Compare
|
Yay, all green! |
|
Ah, quick addon, i noticed this actually does* present errors when referencing error[E0422]: cannot find struct, variant or union type `ErrorResponse` in module `kube::error`
--> src/controller/reconcile.rs:129:39
|
129 | kube::Error::Api(kube::error::ErrorResponse { code: 403, .. }) => {
| ^^^^^^^^^^^^^ not found in `kube::error`
For more information about this error, try `rustc --explain E0422`.
error: could not compile `xctrl` (lib) due to 1 previous errorI think the ErrorResponse type alias also need to exist in the places we export Status now. EDIT: doing this in #1883 |
* Add more unit tests Signed-off-by: Cyril Plisko <[email protected]> * Replace kube::Error::Api playload with Status Signed-off-by: Cyril Plisko <[email protected]> * Box the Status object to make clippy happy Signed-off-by: Cyril Plisko <[email protected]> * Address code review comments Signed-off-by: Cyril Plisko <[email protected]> * Replace ErrorResponse with deprecated type alias Signed-off-by: Cyril Plisko <[email protected]> --------- Signed-off-by: Cyril Plisko <[email protected]>
* Add more unit tests Signed-off-by: Cyril Plisko <[email protected]> * Replace kube::Error::Api playload with Status Signed-off-by: Cyril Plisko <[email protected]> * Box the Status object to make clippy happy Signed-off-by: Cyril Plisko <[email protected]> * Address code review comments Signed-off-by: Cyril Plisko <[email protected]> * Replace ErrorResponse with deprecated type alias Signed-off-by: Cyril Plisko <[email protected]> --------- Signed-off-by: Cyril Plisko <[email protected]>
This addresses #40 and by extension #1862
Motivation
This is done in order to expose the entire API
Statusdata as close as possible to themetav1::Statusobject.Solution
The
Statusstruct is used as a payload inkube::Error::Apivariant effectively bringing all the data from the (failed) k8s API request.Also a bunch of constants added for different values of
reasonfield (the list of reasons is shamelessly stolen from the K8s Go code base) as well as a fewStatusmethods for identifying a popular error situation.The implementation is also inspired by that of the Kubernetes.
I'd like to solicit opinions if that feels like a correct approach?
For example I was not entirely sure whether to convert the reason field to Rust enum instead of
String. Do folks think that would be a right thing to do? I mean usually it is a good thing in Rust world, but in this specific case it might be rather large addition of LoCs with relatively low value. Would love to hear your thoughts.I didn't touch yet the original
ErrorResponsestruct, but it could be of course aliased to theStatusor alternatively madeFrom<Status>provided we agree on the rest.