@@ -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)
@@ -303,7 +303,7 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
303
303
registryClient, file, err := r.RegistryClientGenerator(logOpts != nil)
304
304
if err != nil {
305
305
e := &serror.Stalling{
306
- Err: fmt.Errorf("failed to create registry client:: %w", err),
306
+ Err: fmt.Errorf("failed to create registry client: %w", err),
307
307
Reason: meta.FailedReason,
308
308
}
309
309
conditions.MarkFalse(obj, meta.ReadyCondition, e.Reason, e.Err.Error())
@@ -312,7 +312,17 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
312
312
313
313
if file != "" {
314
314
defer func() {
315
- os.Remove(file)
315
+ if err := os.Remove(file); err != nil {
316
+ log := ctrl.LoggerFrom(ctx)
317
+ log.Error(err, "failed to delete temporary credentials file")
318
+ r.Eventf(
319
+ obj,
320
+ corev1.EventTypeWarning,
321
+ meta.FailedReason,
322
+ "failed to delete temporary credentials file: %s",
323
+ err,
324
+ )
325
+ }
316
326
}()
317
327
}
318
328
0 commit comments