Skip to content

Commit

Permalink
owns and watches is actually a specialization on DynamicType - fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Jul 2, 2021
1 parent eb3eb98 commit 8ac7c48
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,22 +474,13 @@ where
/// The `api` must have the correct scope (cluster/all namespaces, or namespaced)
///
/// [`OwnerReference`]: https://docs.rs/k8s-openapi/0.10.0/k8s_openapi/apimachinery/pkg/apis/meta/v1/struct.OwnerReference.html
pub fn owns_with<Child: Clone + Resource + DeserializeOwned + Debug + Send + 'static>(
mut self,
pub fn owns<Child: Clone + Resource<DynamicType=()> + DeserializeOwned + Debug + Send + 'static>(
self,
api: Api<Child>,
dyntype: Child::DynamicType,
lp: ListParams,
) -> Self
where
Child::DynamicType: Debug + Eq + Hash + Clone,
{
let child_watcher = trigger_owners(
try_flatten_touched(watcher(api, lp)),
self.dyntype.clone(),
dyntype,
);
self.trigger_selector.push(child_watcher.boxed());
self
self.owns_with(api, (), lp)
}

/// Indicate child objets `K` owns and be notified when they change
Expand All @@ -500,32 +491,38 @@ where
/// The `api` must have the correct scope (cluster/all namespaces, or namespaced)
///
/// [`OwnerReference`]: https://docs.rs/k8s-openapi/0.10.0/k8s_openapi/apimachinery/pkg/apis/meta/v1/struct.OwnerReference.html
pub fn owns<Child: Clone + Resource + DeserializeOwned + Debug + Send + 'static>(
pub fn owns_with<Child: Clone + Resource + DeserializeOwned + Debug + Send + 'static>(
mut self,
api: Api<Child>,
dyntype: Child::DynamicType,
lp: ListParams,
) -> Self
where
Child::DynamicType: Debug + Eq + Hash + Clone,
{
self.owns_with(api, (), lp)
let child_watcher = trigger_owners(
try_flatten_touched(watcher(api, lp)),
self.dyntype.clone(),
dyntype,
);
self.trigger_selector.push(child_watcher.boxed());
self
}

/// Indicate an object to watch with a custom mapper
///
/// This mapper should return something like `Option<ObjectRef<K>>`
pub fn watches<
Other: Clone + Resource + DeserializeOwned + Debug + Send + 'static,
Other: Clone + Resource<DynamicType=()> + DeserializeOwned + Debug + Send + 'static,
I: 'static + IntoIterator<Item = ObjectRef<K>>,
>(
mut self,
self,
api: Api<Other>,
lp: ListParams,
mapper: impl Fn(Other) -> I + Sync + Send + 'static,
) -> Self
where
I::IntoIter: Send,
Other::DynamicType: Clone,
{
self.watches_with(api, (), lp, mapper)
}
Expand Down

0 comments on commit 8ac7c48

Please sign in to comment.