From c57eadb8a7ea6709eefd6b79dc773b8967b2d39d Mon Sep 17 00:00:00 2001 From: clux Date: Wed, 11 May 2022 21:36:25 +0100 Subject: [PATCH] Rename unreleased watcher ext methods slightly as suggested by https://github.com/kube-rs/kube-rs/pull/899#pullrequestreview-969920445 Signed-off-by: clux --- examples/configmap_reflector.rs | 2 +- examples/crd_reflector.rs | 2 +- examples/dynamic_watcher.rs | 2 +- examples/event_watcher.rs | 2 +- examples/kubectl.rs | 2 +- examples/multi_watcher.rs | 6 +++--- examples/node_reflector.rs | 2 +- examples/node_watcher.rs | 2 +- examples/pod_watcher.rs | 2 +- examples/secret_reflector.rs | 2 +- kube-runtime/src/controller/mod.rs | 6 +++--- kube-runtime/src/utils/event_flatten.rs | 2 +- kube-runtime/src/utils/mod.rs | 4 ++-- kube-runtime/src/utils/watch_ext.rs | 4 ++-- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/configmap_reflector.rs b/examples/configmap_reflector.rs index b00c9a66e..fbf852cb1 100644 --- a/examples/configmap_reflector.rs +++ b/examples/configmap_reflector.rs @@ -32,7 +32,7 @@ async fn main() -> anyhow::Result<()> { spawn_periodic_reader(reader); // read from a reader in the background - let mut applied_events = rf.watch_applies().boxed_local(); + let mut applied_events = rf.applied_objects().boxed_local(); while let Some(event) = applied_events.try_next().await? { info!("saw {}", event.name()) } diff --git a/examples/crd_reflector.rs b/examples/crd_reflector.rs index e89727bf2..072f79d38 100644 --- a/examples/crd_reflector.rs +++ b/examples/crd_reflector.rs @@ -48,7 +48,7 @@ async fn main() -> anyhow::Result<()> { info!("Current crds: {:?}", crds); } }); - let mut rfa = rf.watch_applies().boxed(); + let mut rfa = rf.applied_objects().boxed(); while let Some(event) = rfa.try_next().await? { info!("saw {}", event.name()); } diff --git a/examples/dynamic_watcher.rs b/examples/dynamic_watcher.rs index 3fb493eb5..130cb2157 100644 --- a/examples/dynamic_watcher.rs +++ b/examples/dynamic_watcher.rs @@ -28,7 +28,7 @@ async fn main() -> anyhow::Result<()> { let api = Api::::all_with(client, &ar); // Fully compatible with kube-runtime - let mut items = watcher(api, ListParams::default()).watch_applies().boxed(); + let mut items = watcher(api, ListParams::default()).applied_objects().boxed(); while let Some(p) = items.try_next().await? { if caps.scope == Scope::Cluster { info!("saw {}", p.name()); diff --git a/examples/event_watcher.rs b/examples/event_watcher.rs index 57714abed..18e037cba 100644 --- a/examples/event_watcher.rs +++ b/examples/event_watcher.rs @@ -15,7 +15,7 @@ async fn main() -> anyhow::Result<()> { let events: Api = Api::all(client); let lp = ListParams::default(); - let ew = watcher(events, lp).watch_applies(); + let ew = watcher(events, lp).applied_objects(); pin_mut!(ew); while let Some(event) = ew.try_next().await? { diff --git a/examples/kubectl.rs b/examples/kubectl.rs index be2ac077b..2af7a6ac1 100644 --- a/examples/kubectl.rs +++ b/examples/kubectl.rs @@ -118,7 +118,7 @@ impl App { lp = lp.fields(&format!("metadata.name={}", n)); } // present a dumb table for it for now. kubectl does not do this anymore. - let mut stream = watcher(api, lp).watch_applies().boxed(); + let mut stream = watcher(api, lp).applied_objects().boxed(); println!("{0: anyhow::Result<()> { // select on applied events from all watchers let mut combo_stream = stream::select_all(vec![ - dep_watcher.watch_applies().map_ok(Watched::Deploy).boxed(), - cm_watcher.watch_applies().map_ok(Watched::Config).boxed(), - sec_watcher.watch_applies().map_ok(Watched::Secret).boxed(), + dep_watcher.applied_objects().map_ok(Watched::Deploy).boxed(), + cm_watcher.applied_objects().map_ok(Watched::Config).boxed(), + sec_watcher.applied_objects().map_ok(Watched::Secret).boxed(), ]); // SelectAll Stream elements must have the same Item, so all packed in this: #[allow(clippy::large_enum_variant)] diff --git a/examples/node_reflector.rs b/examples/node_reflector.rs index 21fa4b850..2822e19a8 100644 --- a/examples/node_reflector.rs +++ b/examples/node_reflector.rs @@ -31,7 +31,7 @@ async fn main() -> anyhow::Result<()> { }); // Drain and log applied events from the reflector - let mut rfa = rf.watch_applies().boxed(); + let mut rfa = rf.applied_objects().boxed(); while let Some(event) = rfa.try_next().await? { info!("saw {}", event.name()); } diff --git a/examples/node_watcher.rs b/examples/node_watcher.rs index 10e25be8c..971e127aa 100644 --- a/examples/node_watcher.rs +++ b/examples/node_watcher.rs @@ -18,7 +18,7 @@ async fn main() -> anyhow::Result<()> { let lp = ListParams::default().labels("beta.kubernetes.io/arch=amd64"); let obs = watcher(nodes, lp) .backoff(ExponentialBackoff::default()) - .watch_applies(); + .applied_objects(); pin_mut!(obs); while let Some(n) = obs.try_next().await? { diff --git a/examples/pod_watcher.rs b/examples/pod_watcher.rs index a5023690b..d47c17dfe 100644 --- a/examples/pod_watcher.rs +++ b/examples/pod_watcher.rs @@ -14,7 +14,7 @@ async fn main() -> anyhow::Result<()> { let api = Api::::default_namespaced(client); watcher(api, ListParams::default()) - .watch_applies() + .applied_objects() .try_for_each(|p| async move { info!("saw {}", p.name()); if let Some(unready_reason) = pod_unready(&p) { diff --git a/examples/secret_reflector.rs b/examples/secret_reflector.rs index 13039c6fa..9ebd16482 100644 --- a/examples/secret_reflector.rs +++ b/examples/secret_reflector.rs @@ -60,7 +60,7 @@ async fn main() -> anyhow::Result<()> { let rf = reflector(store, watcher(secrets, lp)); spawn_periodic_reader(reader); // read from a reader in the background - rf.watch_applies() + rf.applied_objects() .try_for_each(|s| async move { info!("saw: {}", s.name()); Ok(()) diff --git a/kube-runtime/src/controller/mod.rs b/kube-runtime/src/controller/mod.rs index 995a0077e..176c68d4f 100644 --- a/kube-runtime/src/controller/mod.rs +++ b/kube-runtime/src/controller/mod.rs @@ -462,7 +462,7 @@ where let reader = writer.as_reader(); let mut trigger_selector = stream::SelectAll::new(); let self_watcher = trigger_self( - reflector(writer, watcher(owned_api, lp)).watch_applies(), + reflector(writer, watcher(owned_api, lp)).applied_objects(), dyntype.clone(), ) .boxed(); @@ -532,7 +532,7 @@ where where Child::DynamicType: Debug + Eq + Hash + Clone, { - let child_watcher = trigger_owners(watcher(api, lp).watch_touches(), self.dyntype.clone(), dyntype); + let child_watcher = trigger_owners(watcher(api, lp).touched_objects(), self.dyntype.clone(), dyntype); self.trigger_selector.push(child_watcher.boxed()); self } @@ -583,7 +583,7 @@ where I::IntoIter: Send, Other::DynamicType: Clone, { - let other_watcher = trigger_with(watcher(api, lp).watch_touches(), move |obj| { + let other_watcher = trigger_with(watcher(api, lp).touched_objects(), move |obj| { let watched_obj_ref = ObjectRef::from_obj_with(&obj, dyntype.clone()).erase(); mapper(obj) .into_iter() diff --git a/kube-runtime/src/utils/event_flatten.rs b/kube-runtime/src/utils/event_flatten.rs index 51914c90c..b4834662b 100644 --- a/kube-runtime/src/utils/event_flatten.rs +++ b/kube-runtime/src/utils/event_flatten.rs @@ -7,7 +7,7 @@ use futures::{ready, Stream, TryStream}; use pin_project::pin_project; #[pin_project] -/// Stream returned by the [`watch_applies`](super::WatchStreamExt::watch_applies) and [`watch_touches`](super::WatchStreamExt::watch_touches) method. +/// Stream returned by the [`applied_objects`](super::WatchStreamExt::applied_objects) and [`touched_objects`](super::WatchStreamExt::touched_objects) method. #[must_use = "streams do nothing unless polled"] pub struct EventFlatten { #[pin] diff --git a/kube-runtime/src/utils/mod.rs b/kube-runtime/src/utils/mod.rs index 5c3e52a3a..999c121a4 100644 --- a/kube-runtime/src/utils/mod.rs +++ b/kube-runtime/src/utils/mod.rs @@ -28,7 +28,7 @@ use tokio::{runtime::Handle, task::JoinHandle}; /// Flattens each item in the list following the rules of [`watcher::Event::into_iter_applied`]. #[deprecated( since = "0.72.0", - note = "fn replaced with the WatchStreamExt::watch_applies which can be chained onto watcher. Add `use kube::runtime::WatchStreamExt;` and call `stream.watch_applies()` instead. This function will be removed in 0.75.0." + note = "fn replaced with the WatchStreamExt::applied_objects which can be chained onto watcher. Add `use kube::runtime::WatchStreamExt;` and call `stream.applied_objects()` instead. This function will be removed in 0.75.0." )] pub fn try_flatten_applied>>( stream: S, @@ -41,7 +41,7 @@ pub fn try_flatten_applied>>( /// Flattens each item in the list following the rules of [`watcher::Event::into_iter_touched`]. #[deprecated( since = "0.72.0", - note = "fn replaced with the WatchStreamExt::watch_touches which can be chained onto watcher. Add `use kube::runtime::WatchStreamExt;` and call `stream.watch_touches()` instead. This function will be removed in 0.75.0." + note = "fn replaced with the WatchStreamExt::touched_objects which can be chained onto watcher. Add `use kube::runtime::WatchStreamExt;` and call `stream.touched_objects()` instead. This function will be removed in 0.75.0." )] pub fn try_flatten_touched>>( stream: S, diff --git a/kube-runtime/src/utils/watch_ext.rs b/kube-runtime/src/utils/watch_ext.rs index 4a43f33fc..018ad4cca 100644 --- a/kube-runtime/src/utils/watch_ext.rs +++ b/kube-runtime/src/utils/watch_ext.rs @@ -21,7 +21,7 @@ pub trait WatchStreamExt: Stream { /// /// All Added/Modified events are passed through, and critical errors bubble up. /// This is functionally equivalent to calling [`try_flatten_applied`] on a [`watcher`]. - fn watch_applies(self) -> EventFlatten + fn applied_objects(self) -> EventFlatten where Self: Stream, watcher::Error>> + Sized, { @@ -32,7 +32,7 @@ pub trait WatchStreamExt: Stream { /// /// All Added/Modified/Deleted events are passed through, and critical errors bubble up. /// This is functionally equivalent to calling [`try_flatten_touched`] on a [`watcher`]. - fn watch_touches(self) -> EventFlatten + fn touched_objects(self) -> EventFlatten where Self: Stream, watcher::Error>> + Sized, {