From c30864435d3fd55a83017273209a394b32fb8092 Mon Sep 17 00:00:00 2001 From: Jess Bodzo Date: Fri, 29 Dec 2023 15:58:14 -0500 Subject: [PATCH] Adds ability to elide namespace on trigger_owners Signed-off-by: Jess Bodzo --- kube-runtime/src/controller/mod.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kube-runtime/src/controller/mod.rs b/kube-runtime/src/controller/mod.rs index ef4c662a7..c9229888d 100644 --- a/kube-runtime/src/controller/mod.rs +++ b/kube-runtime/src/controller/mod.rs @@ -158,6 +158,7 @@ pub fn trigger_owners( stream: S, owner_type: KOwner::DynamicType, child_type: ::DynamicType, + owner_inherits_namespace: bool, ) -> impl Stream, S::Error>> where S: TryStream, @@ -168,7 +169,10 @@ where { let mapper = move |obj: S::Ok| { let meta = obj.meta().clone(); - let ns = meta.namespace; + let ns = match owner_inherits_namespace { + true => meta.namespace, + false => None, + }; let owner_type = owner_type.clone(); meta.owner_references .into_iter() @@ -762,6 +766,7 @@ where metadata_watcher(api, wc).touched_objects(), self.dyntype.clone(), dyntype, + true, ); self.trigger_selector.push(child_watcher.boxed()); self @@ -830,7 +835,7 @@ where where Child::DynamicType: Debug + Eq + Hash + Clone, { - let child_watcher = trigger_owners(trigger, self.dyntype.clone(), dyntype); + let child_watcher = trigger_owners(trigger, self.dyntype.clone(), dyntype, true); self.trigger_selector.push(child_watcher.boxed()); self } @@ -1155,7 +1160,7 @@ where /// use kube::{Api, Client, ResourceExt}; /// use kube_runtime::{ /// controller::{Controller, Action}, - /// watcher, + /// watcher, /// }; /// use std::{convert::Infallible, sync::Arc}; /// Controller::new(