@@ -41,7 +41,7 @@ pub struct CustomResourceDefinitionMaintainer {
41
41
definitions : Vec < CustomResourceDefinition > ,
42
42
options : CustomResourceDefinitionMaintainerOptions ,
43
43
44
- initial_reconcile_tx : Option < oneshot:: Sender < ( ) > > ,
44
+ initial_reconcile_tx : oneshot:: Sender < ( ) > ,
45
45
}
46
46
47
47
impl CustomResourceDefinitionMaintainer {
@@ -120,7 +120,6 @@ impl CustomResourceDefinitionMaintainer {
120
120
options : CustomResourceDefinitionMaintainerOptions ,
121
121
) -> ( Self , oneshot:: Receiver < ( ) > ) {
122
122
let ( initial_reconcile_tx, initial_reconcile_rx) = oneshot:: channel ( ) ;
123
- let initial_reconcile_tx = Some ( initial_reconcile_tx) ;
124
123
125
124
let maintainer = Self {
126
125
definitions : definitions. into_iter ( ) . collect ( ) ,
@@ -153,6 +152,11 @@ impl CustomResourceDefinitionMaintainer {
153
152
return Ok ( ( ) ) ;
154
153
}
155
154
155
+ // This channel can only be used exactly once. The sender's send method consumes self, and
156
+ // as such, the sender is wrapped in an Option to be able to call take to consume the inner
157
+ // value.
158
+ let mut initial_reconcile_tx = Some ( self . initial_reconcile_tx ) ;
159
+
156
160
// This get's polled by the async runtime on a regular basis (or when woken up). Once we
157
161
// receive a message containing the newly generated TLS certificate for the conversion
158
162
// webhook, we need to update the caBundle in the CRD.
@@ -214,10 +218,8 @@ impl CustomResourceDefinitionMaintainer {
214
218
}
215
219
216
220
// After the reconciliation of the CRDs, the initial reconcile heartbeat is sent out
217
- // via the oneshot channel. This channel can only be used exactly once. The sender's
218
- // send method consumes self, and as such, the sender is wrapped in an Option to be
219
- // able to call take to consume the inner value.
220
- if let Some ( initial_reconcile_tx) = self . initial_reconcile_tx . take ( ) {
221
+ // via the oneshot channel.
222
+ if let Some ( initial_reconcile_tx) = initial_reconcile_tx. take ( ) {
221
223
match initial_reconcile_tx. send ( ( ) ) {
222
224
Ok ( _) => { }
223
225
Err ( _) => return SendInitialReconcileHeartbeatSnafu . fail ( ) ,
0 commit comments