@@ -171,7 +171,7 @@ func (r *HelmRepositoryOCIReconciler) Reconcile(ctx context.Context, req ctrl.Re
171171 r .Metrics .RecordDuration (ctx , obj , start )
172172 }()
173173
174- // Add finalizer first if not exist to avoid the race condition
174+ // Add finalizer first if it doesn't exist to avoid the race condition
175175 // between init and delete
176176 if ! controllerutil .ContainsFinalizer (obj , sourcev1 .SourceFinalizer ) {
177177 controllerutil .AddFinalizer (obj , sourcev1 .SourceFinalizer )
@@ -222,6 +222,7 @@ func (r *HelmRepositoryOCIReconciler) notify(oldObj, newObj *sourcev1.HelmReposi
222222}
223223
224224func (r * HelmRepositoryOCIReconciler ) reconcile (ctx context.Context , obj * sourcev1.HelmRepository , reconcilers []helmRepositoryOCIReconcileFunc ) (sreconcile.Result , error ) {
225+
225226 oldObj := obj .DeepCopy ()
226227
227228 // Mark as reconciling if generation differs.
@@ -303,7 +304,7 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
303304 registryClient , file , err := r .RegistryClientGenerator (logOpts != nil )
304305 if err != nil {
305306 e := & serror.Stalling {
306- Err : fmt .Errorf ("failed to create registry client:: %w" , err ),
307+ Err : fmt .Errorf ("failed to create registry client: %w" , err ),
307308 Reason : meta .FailedReason ,
308309 }
309310 conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
@@ -312,7 +313,17 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
312313
313314 if file != "" {
314315 defer func () {
315- os .Remove (file )
316+ if err := os .Remove (file ); err != nil {
317+ log := ctrl .LoggerFrom (ctx )
318+ log .Error (err , "failed to delete temporary credentials file" )
319+ r .Eventf (
320+ obj ,
321+ corev1 .EventTypeWarning ,
322+ meta .FailedReason ,
323+ "failed to delete temporary credentials file: %s" ,
324+ err ,
325+ )
326+ }
316327 }()
317328 }
318329
0 commit comments