@@ -182,7 +182,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
182182 }
183183
184184 // Configure custom health checks.
185- statusReaders , err := cel .PollerWithCustomHealthChecks ( ctx , obj .Spec .HealthCheckExprs )
185+ statusReader , err := cel .NewStatusReader ( obj .Spec .HealthCheckExprs )
186186 if err != nil {
187187 errMsg := fmt .Sprintf ("%s: %v" , TerminalErrorMessage , err )
188188 conditions .MarkFalse (obj , meta .ReadyCondition , meta .InvalidCELExpressionReason , "%s" , errMsg )
@@ -260,7 +260,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
260260 }
261261
262262 // Reconcile the latest revision.
263- reconcileErr := r .reconcile (ctx , obj , artifactSource , patcher , statusReaders )
263+ reconcileErr := r .reconcile (ctx , obj , artifactSource , patcher , statusReader )
264264
265265 // Requeue at the specified retry interval if the artifact tarball is not found.
266266 if errors .Is (reconcileErr , fetch .ErrFileNotFound ) {
@@ -304,7 +304,7 @@ func (r *KustomizationReconciler) reconcile(
304304 obj * kustomizev1.Kustomization ,
305305 src sourcev1.Source ,
306306 patcher * patch.SerialPatcher ,
307- statusReaders [] func (apimeta.RESTMapper ) engine.StatusReader ) error {
307+ statusReader func (apimeta.RESTMapper ) engine.StatusReader ) error {
308308 reconcileStart := time .Now ()
309309 log := ctrl .LoggerFrom (ctx )
310310
@@ -392,9 +392,9 @@ func (r *KustomizationReconciler) reconcile(
392392 impersonatorOpts = append (impersonatorOpts ,
393393 runtimeClient .WithKubeConfig (obj .Spec .KubeConfig , r .KubeConfigOpts , obj .GetNamespace (), provider ))
394394 }
395- if r .ClusterReader != nil || len (statusReaders ) > 0 {
395+ if r .ClusterReader != nil || len (obj . Spec . HealthCheckExprs ) > 0 {
396396 impersonatorOpts = append (impersonatorOpts ,
397- runtimeClient .WithPolling (r .ClusterReader , statusReaders ... ))
397+ runtimeClient .WithPolling (r .ClusterReader , statusReader ))
398398 }
399399 impersonation := runtimeClient .NewImpersonator (r .Client , impersonatorOpts ... )
400400
@@ -404,7 +404,7 @@ func (r *KustomizationReconciler) reconcile(
404404 if mustImpersonate {
405405 kubeClient , statusPoller , err = impersonation .GetClient (ctx )
406406 } else {
407- kubeClient , statusPoller = r .getClientAndPoller (statusReaders )
407+ kubeClient , statusPoller = r .getClientAndPoller (obj , statusReader )
408408 }
409409 if err != nil {
410410 conditions .MarkFalse (obj , meta .ReadyCondition , meta .ReconciliationFailedReason , "%s" , err )
@@ -1286,13 +1286,14 @@ func (r *KustomizationReconciler) patch(ctx context.Context,
12861286// Should be used for reconciliations that are not configured to use
12871287// ServiceAccount impersonation or kubeconfig.
12881288func (r * KustomizationReconciler ) getClientAndPoller (
1289- readerCtors []func (apimeta.RESTMapper ) engine.StatusReader ,
1289+ obj * kustomizev1.Kustomization ,
1290+ readerCtor func (apimeta.RESTMapper ) engine.StatusReader ,
12901291) (client.Client , * polling.StatusPoller ) {
12911292
1292- readers := make ([]engine.StatusReader , 0 , 1 + len (readerCtors ))
1293+ readers := make ([]engine.StatusReader , 0 , 1 + len (obj . Spec . HealthCheckExprs ))
12931294 readers = append (readers , statusreaders .NewCustomJobStatusReader (r .Mapper ))
1294- for _ , ctor := range readerCtors {
1295- readers = append (readers , ctor (r .Mapper ))
1295+ if len ( obj . Spec . HealthCheckExprs ) > 0 {
1296+ readers = append (readers , readerCtor (r .Mapper ))
12961297 }
12971298
12981299 poller := polling .NewStatusPoller (r .Client , r .Mapper , polling.Options {
0 commit comments