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

Update kubectl example to include optional context argument #1647

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

mgs255
Copy link
Contributor

@mgs255 mgs255 commented Nov 23, 2024

Allow overriding current context with the named context from the user's kubeconfig file.

Motivation

Small extension to the kubectl example, mirroring the functionality provided by the official kubectl tool.
There is not a similar example in the examples codebase of using the KubeConfigOptions.

Solution

Switch from the existing Client::try_default().await? implementation to one that is hopefully equivalent and also supports optionally specifying a named context.

Allow overriding current context with the named context from
the user's kubeconfig file.

Signed-off-by: Michael Sommerville <[email protected]>
Comment on lines +192 to +196
let options = KubeConfigOptions {
context: app.context.clone(),
cluster: None,
user: None,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks sensible to me. kind of highlights that perhaps KubeConfigOptions should have a builder so that these 4 lines becomes would become let options = KubeConfigOptions::default().context(app.context);.

@clux clux added the changelog-exclude changelog excluded prs label Nov 23, 2024
@clux clux added this to the 0.98.0 milestone Nov 23, 2024
Copy link

codecov bot commented Nov 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.6%. Comparing base (8b5230f) to head (c9b9ab5).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1647     +/-   ##
=======================================
+ Coverage   75.3%   75.6%   +0.3%     
=======================================
  Files         82      82             
  Lines       7371    7405     +34     
=======================================
+ Hits        5550    5591     +41     
+ Misses      1821    1814      -7     

see 7 files with indirect coverage changes

---- 🚨 Try these New Features:

@clux clux merged commit 3ee4ae5 into kube-rs:main Nov 23, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-exclude changelog excluded prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants