You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a little command like app, which like kubectl allows the user to specify --context and --namespace args. Here we're creating a client for the Endpoints Api:
let client = if arguments.get_context().is_some() {
let options = KubeConfigOptions {
context: arguments.get_context(),
cluster: None,
user: None,
};
let config = kube::Config::from_kubeconfig(&options).await?;
Client::try_from(config)?
} else {
Client::try_default().await?
};
let endpoints: Api<Endpoints> = if let Some(n) = arguments.get_namespace() {
Api::namespaced(client, &n)
} else {
Api::default_namespaced(client)
};
Being a bit of rust noobie, this took me a while to come up without any examples. Would it be worthwhile including something like this in the kubectl example app? Maybe something like this?
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let app: App = clap::Parser::parse();
let options = KubeConfigOptions {
context: app.context,
cluster: None,
user: None,
};
let config = kube::Config::from_kubeconfig(&options).await?;
let client = Client::try_from(config)?;
...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi.
I have a little command like app, which like kubectl allows the user to specify
--context
and--namespace
args. Here we're creating a client for the Endpoints Api:Being a bit of rust noobie, this took me a while to come up without any examples. Would it be worthwhile including something like this in the
kubectl
example app? Maybe something like this?Where the app has been extended with:
Beta Was this translation helpful? Give feedback.
All reactions