diff --git a/examples/secret_syncer.rs b/examples/secret_syncer.rs index 3b1bdba44..f489cd97c 100644 --- a/examples/secret_syncer.rs +++ b/examples/secret_syncer.rs @@ -14,7 +14,7 @@ use kube::{ finalizer::{finalizer, Event}, }, }; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; use thiserror::Error; #[derive(Debug, Error)] @@ -37,7 +37,7 @@ fn secret_name_for_configmap(cm: &ConfigMap) -> Result { )) } -async fn apply(cm: ConfigMap, secrets: &kube::Api) -> Result { +async fn apply(cm: Arc, secrets: &kube::Api) -> Result { println!("Reconciling {:?}", cm); let secret_name = secret_name_for_configmap(&cm)?; secrets @@ -49,8 +49,8 @@ async fn apply(cm: ConfigMap, secrets: &kube::Api) -> Result) -> Result) -> Result { +async fn cleanup(cm: Arc, secrets: &kube::Api) -> Result { println!("Cleaning up {:?}", cm); secrets .delete(&secret_name_for_configmap(&cm)?, &DeleteParams::default()) diff --git a/kube-runtime/src/finalizer.rs b/kube-runtime/src/finalizer.rs index da7939b7f..14dd08617 100644 --- a/kube-runtime/src/finalizer.rs +++ b/kube-runtime/src/finalizer.rs @@ -113,7 +113,7 @@ where FinalizerState { finalizer_index: Some(_), is_deleting: false, - } => reconcile(Event::Apply(obj.as_ref().clone())) + } => reconcile(Event::Apply(obj)) .into_future() .await .map_err(Error::ApplyFailed), @@ -123,7 +123,7 @@ where } => { // Cleanup reconciliation must succeed before it's safe to remove the finalizer let name = obj.meta().name.clone().ok_or(Error::UnnamedObject)?; - let action = reconcile(Event::Cleanup(obj.as_ref().clone())) + let action = reconcile(Event::Cleanup(obj)) .into_future() .await // Short-circuit, so that we keep the finalizer if cleanup fails @@ -200,7 +200,7 @@ pub enum Event { /// - The object is updated /// - The reconciliation fails /// - The grinch attacks - Apply(K), + Apply(Arc), /// The object is being deleted, and the reconciler should remove all resources that it owns. /// /// This must be idempotent, since it may be recalled if, for example (this list is non-exhaustive): @@ -209,5 +209,5 @@ pub enum Event { /// - The reconciliation fails /// - Another finalizer was removed in the meantime /// - The grinch's heart grows a size or two - Cleanup(K), + Cleanup(Arc), }