@@ -171,7 +171,7 @@ func (r *HelmRepositoryOCIReconciler) Reconcile(ctx context.Context, req ctrl.Re
171
171
r .Metrics .RecordDuration (ctx , obj , start )
172
172
}()
173
173
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
175
175
// between init and delete
176
176
if ! controllerutil .ContainsFinalizer (obj , sourcev1 .SourceFinalizer ) {
177
177
controllerutil .AddFinalizer (obj , sourcev1 .SourceFinalizer )
@@ -222,6 +222,7 @@ func (r *HelmRepositoryOCIReconciler) notify(oldObj, newObj *sourcev1.HelmReposi
222
222
}
223
223
224
224
func (r * HelmRepositoryOCIReconciler ) reconcile (ctx context.Context , obj * sourcev1.HelmRepository , reconcilers []helmRepositoryOCIReconcileFunc ) (sreconcile.Result , error ) {
225
+
225
226
oldObj := obj .DeepCopy ()
226
227
227
228
// Mark as reconciling if generation differs.
@@ -303,7 +304,7 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
303
304
registryClient , file , err := r .RegistryClientGenerator (logOpts != nil )
304
305
if err != nil {
305
306
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 ),
307
308
Reason : meta .FailedReason ,
308
309
}
309
310
conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
@@ -312,7 +313,17 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
312
313
313
314
if file != "" {
314
315
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
+ }
316
327
}()
317
328
}
318
329
0 commit comments