Skip to content

Commit

Permalink
example that always breaks #219
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Apr 6, 2020
1 parent 7f82abb commit ae0195d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions kube/examples/configmap_informer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#[macro_use] extern crate log;
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::ConfigMap;
use kube::{
api::{Api, ListParams},
runtime::Informer,
Client,
};

/// Example way to read secrets
#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

let cms: Api<ConfigMap> = Api::namespaced(client, &namespace);
let lp = ListParams::default().timeout(10); // short watch timeout in this example
let inf = Informer::new(cms).params(lp);

loop {
let mut stream = inf.poll().await?.boxed();
while let Some(event) = stream.try_next().await? {
info!("Got: {:?}", event);
}
}
}

0 comments on commit ae0195d

Please sign in to comment.