Skip to content
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

Export functionality to load Kubeconfig from text #718

Closed
imp opened this issue Nov 18, 2021 · 2 comments · Fixed by #719
Closed

Export functionality to load Kubeconfig from text #718

imp opened this issue Nov 18, 2021 · 2 comments · Fixed by #719
Assignees
Labels
config Kube config related help wanted Not immediately prioritised, please help!
Milestone

Comments

@imp
Copy link
Contributor

imp commented Nov 18, 2021

Would you like to work on this feature?

yes

What problem are you trying to solve?

Besides loading Kubeconfig from files or env var, there are situations where you have plain text coming from somewhere else, rather than a file. For example, when working with ClusterAPI the Kubeconfig is stored in the secret. It might be a good idea to provide an impl FromStr for Kubeconfig and let every other higher-level functions just use it.

Describe the solution you'd like

impl FromStr for Kubeconfig

Describe alternatives you've considered

An alternative would be to write just a free-standing function or just implement it (really two-liners) in your own code.

Documentation, Adoption, Migration Strategy

Well, the use should be straightforward, via parse() method

Target crate for feature

kube-client

@kazk
Copy link
Member

kazk commented Nov 18, 2021

Like this?

let config: Kubeconfig = serde_yaml::from_str(secret).unwrap();

imp added a commit to imp/kube-rs that referenced this issue Nov 18, 2021
Also add Kubeconfig::from_text()

Fixes kube-rs#718
@clux
Copy link
Member

clux commented Nov 18, 2021

I guess it makes sense to expose something that does what Kubeconfig::read_from does in the absense of a file path now that we handle multi-doc kubeconfigs. Plus it potentially allows users to not having to manually specify serde_yaml in their cargo toml if this is their only use case.

I'm 👍 . Happy to review a PR.

@clux clux added config Kube config related help wanted Not immediately prioritised, please help! labels Nov 18, 2021
@clux clux assigned imp Nov 18, 2021
imp added a commit to imp/kube-rs that referenced this issue Nov 18, 2021
Also add Kubeconfig::from_text()

Fixes kube-rs#718

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
@clux clux linked a pull request Nov 18, 2021 that will close this issue
imp added a commit to imp/kube-rs that referenced this issue Nov 20, 2021
Fixes kube-rs#718

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
imp added a commit to imp/kube-rs that referenced this issue Nov 20, 2021
Fixes kube-rs#718

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
@clux clux closed this as completed in #719 Nov 20, 2021
clux added a commit that referenced this issue Nov 20, 2021
* Conditionally derive PartialEq for Kubeconfig and children

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>

* Add helper for parsing kubeconfig YAML text

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>

* Add Kubeconfig::from_yaml

Fixes #718

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>

* Update Kubeconfig::read_from to use YAML helper

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>

* Update unit tests

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>

* Update kube-client/src/config/file_config.rs

Co-authored-by: Eirik A <sszynrae@gmail.com>
@clux clux added this to the 0.65.0 milestone Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Kube config related help wanted Not immediately prioritised, please help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants