Skip to content

Commit

Permalink
upgrade subscriber and swap out eyre (#744)
Browse files Browse the repository at this point in the history
Signed-off-by: clux <sszynrae@gmail.com>
  • Loading branch information
clux committed Dec 6, 2021
1 parent c88addd commit b112388
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
4 changes: 1 addition & 3 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.68"
serde_yaml = "0.8.21"
tokio = { version = "1.14.0", features = ["full"] }
color-eyre = "0.5.10"
# Some Api::delete methods use Either
either = "1.6.1"
schemars = "0.8.6"
static_assertions = "1.1.0"
tar = "0.4.37"
tracing = "0.1.29"
tracing-subscriber = "0.2.25"
tracing-subscriber = "0.3.3"
warp = { version = "0.3", features = ["tls"] }
http = "0.2.5"
json-patch = "0.2.6"
Expand Down
12 changes: 11 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,24 @@ cargo run --example dynamic_watcher
```

### controllers
Requires you creating the custom resource first:
Main example requires you creating the custom resource first:

```sh
kubectl apply -f configmapgen_controller_crd.yaml
cargo run --example configmapgen_controller &
kubectl apply -f configmapgen_controller_object.yaml
```

and the finalizer example (reconciles a labelled subset of configmaps):

```sh
cargo run --example configmapgen_controller
kubectl apply -f secret_syncer_configmap.yaml
kubectl delete -f secret_syncer_configmap.yaml
```

the finalizer is resilient against controller downtime (try stopping the controller before deleting).

### reflectors
These examples watch resources as well as ive a store access point:

Expand Down
4 changes: 2 additions & 2 deletions examples/configmapgen_controller.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[macro_use] extern crate log;
use color_eyre::{Report, Result};
use anyhow::Result;
use futures::StreamExt;
use k8s_openapi::{
api::core::v1::ConfigMap,
Expand Down Expand Up @@ -130,7 +130,7 @@ async fn main() -> Result<()> {
.for_each(|res| async move {
match res {
Ok(o) => info!("reconciled {:?}", o),
Err(e) => warn!("reconcile failed: {}", Report::from(e)),
Err(e) => warn!("reconcile failed: {}", e),
}
})
.await;
Expand Down
3 changes: 1 addition & 2 deletions examples/pod_reflector.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use color_eyre::Result;
use futures::prelude::*;
use k8s_openapi::api::core::v1::Pod;
use kube::{
Expand All @@ -8,7 +7,7 @@ use kube::{
};

#[tokio::main]
async fn main() -> Result<()> {
async fn main() -> anyhow::Result<()> {
let client = Client::try_default().await?;
let namespace = std::env::var("NAMESPACE").unwrap_or_else(|_| "default".into());

Expand Down
3 changes: 1 addition & 2 deletions examples/pod_watcher.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use color_eyre::Result;
use futures::prelude::*;
use k8s_openapi::api::core::v1::Pod;
use kube::{
Expand All @@ -8,7 +7,7 @@ use kube::{
};

#[tokio::main]
async fn main() -> Result<()> {
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
Expand Down
2 changes: 1 addition & 1 deletion examples/secret_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async fn cleanup(cm: ConfigMap, secrets: &kube::Api<Secret>) -> Result<Reconcile
}

#[tokio::main]
async fn main() -> color_eyre::Result<()> {
async fn main() -> anyhow::Result<()> {
env_logger::init();
let kube = kube::Client::try_default().await?;
let all_cms = kube::Api::<ConfigMap>::all(kube.clone());
Expand Down

0 comments on commit b112388

Please sign in to comment.