Skip to content

Commit

Permalink
Merge branch 'main' into feat/derive-typed-scale-arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Techassi authored Dec 2, 2024
2 parents 9537789 + 3ee4ae5 commit 01f89be
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion examples/kubectl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use futures::{StreamExt, TryStreamExt};
use k8s_openapi::{apimachinery::pkg::apis::meta::v1::Time, chrono::Utc};
use kube::{
api::{Api, DynamicObject, ListParams, Patch, PatchParams, ResourceExt},
config::KubeConfigOptions,
core::GroupVersionKind,
discovery::{ApiCapabilities, ApiResource, Discovery, Scope},
runtime::{
Expand All @@ -26,6 +27,8 @@ struct App {
selector: Option<String>,
#[arg(long, short)]
namespace: Option<String>,
#[arg(long, short)]
context: Option<String>,
#[arg(long, short = 'A')]
all: bool,
verb: Verb,
Expand Down Expand Up @@ -185,7 +188,14 @@ impl App {
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let app: App = clap::Parser::parse();
let client = Client::try_default().await?;

let options = KubeConfigOptions {
context: app.context.clone(),
cluster: None,
user: None,
};
let config = kube::Config::from_kubeconfig(&options).await?;
let client = Client::try_from(config)?;

// discovery (to be able to infer apis from kind/plural only)
let discovery = Discovery::new(client.clone()).run().await?;
Expand Down

0 comments on commit 01f89be

Please sign in to comment.