Skip to content

Commit

Permalink
Adds ability to elide namespace on trigger_owners
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Bodzo <[email protected]>
  • Loading branch information
sjbodzo committed Dec 29, 2023
1 parent 00fffed commit c308644
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ pub fn trigger_owners<KOwner, S>(
stream: S,
owner_type: KOwner::DynamicType,
child_type: <S::Ok as Resource>::DynamicType,
owner_inherits_namespace: bool,
) -> impl Stream<Item = Result<ReconcileRequest<KOwner>, S::Error>>
where
S: TryStream,
Expand All @@ -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,

Check warning on line 174 in kube-runtime/src/controller/mod.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/controller/mod.rs#L172-L174

Added lines #L172 - L174 were not covered by tests
};
let owner_type = owner_type.clone();
meta.owner_references
.into_iter()
Expand Down Expand Up @@ -762,6 +766,7 @@ where
metadata_watcher(api, wc).touched_objects(),
self.dyntype.clone(),
dyntype,
true,
);
self.trigger_selector.push(child_watcher.boxed());
self
Expand Down Expand Up @@ -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);

Check warning on line 838 in kube-runtime/src/controller/mod.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/controller/mod.rs#L838

Added line #L838 was not covered by tests
self.trigger_selector.push(child_watcher.boxed());
self
}
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c308644

Please sign in to comment.