Add TryFrom conversions for Kubeconfig -> Config -> Client#1801
Conversation
6d127bc to
6444847
Compare
Signed-off-by: Danil-Grigorev <[email protected]>
6444847 to
afe6004
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1801 +/- ##
=======================================
+ Coverage 75.1% 76.3% +1.2%
=======================================
Files 84 84
Lines 7792 7899 +107
=======================================
+ Hits 5851 6024 +173
+ Misses 1941 1875 -66
🚀 New features to boost your workflow:
|
clux
left a comment
There was a problem hiding this comment.
i think this looks great.
one minor request; you can use it in examples/kubectl to show it off! (it is using the more awkward kubeconfigoptions)
| } | ||
|
|
||
| async fn new_from_loader(loader: ConfigLoader) -> Result<Self, KubeconfigError> { | ||
| fn new_from_loader(loader: ConfigLoader) -> Result<Self, KubeconfigError> { |
There was a problem hiding this comment.
this is technically breaking, and we have avoided changing this in the past due to us potentially loading files via tokio::fs.
i guess it is required for the try_from though, so it's probably worth it.
There was a problem hiding this comment.
All I could find is #1336, and I think in this instance it is a private method signature change, so it shouldn't be? Since it is not a part of any trait and used only internally? My thought on this was that in case async is needed later, it can be duplicated in a separate method.
There was a problem hiding this comment.
ah, you are right, this is internal. i'll change it to changelog-add.
Signed-off-by: Danil-Grigorev <[email protected]>
Motivation
This implementation allows kubeconfig to be directly translated into client using try-from implementation.
Previously, user was required to perform a multi-step manipulation to use custom provided kubeconfig without any modification of context or user, which may not be needed if the kubeconfig was constructed as ready to be used, and multiple sources of kubeconfig are used simultaneously.
Solution
Implement
TryFromtrate for theKubeconfigtoClientconversion.while new approach is a more straightforward version of this, skipping the configuration step: