From b49ab8c117014cc6461ef474200cb958e59b4864 Mon Sep 17 00:00:00 2001 From: Mark Ingram Date: Thu, 12 Sep 2024 19:43:56 +0100 Subject: [PATCH] Stream produced by `watch_object` will include an item when the object isn't in any initial list - added a comment - resolved a nightly clippy - use a match guard instead of an nested if Signed-off-by: Mark Ingram --- kube-runtime/src/watcher.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kube-runtime/src/watcher.rs b/kube-runtime/src/watcher.rs index 0703baa10..63b1503ac 100644 --- a/kube-runtime/src/watcher.rs +++ b/kube-runtime/src/watcher.rs @@ -845,7 +845,13 @@ pub fn watch_object Some(Ok(Some(obj))), + Ok(Event::Apply(obj) | Event::InitApply(obj)) => Some(Ok(Some(obj))), // Pass up `None` for Deleted Ok(Event::Delete(_)) => Some(Ok(None)), - // Ignore marker event - Ok(Event::Init) => None, - // Pass up `None` if the object wasn't seen in any initial list - Ok(Event::InitDone) => { - if obj_seen { - None - } else { - Some(Ok(None)) - } - } + // Pass up `None` if the object wasn't seen in the initial list + Ok(Event::InitDone) if !obj_seen => Some(Ok(None)), + // Ignore marker events + Ok(Event::Init | Event::InitDone) => None, // Bubble up errors Err(err) => Some(Err(err)), }