@@ -173,7 +173,7 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
173
173
}
174
174
175
175
// Always record readiness and duration metrics
176
- r .Metrics .RecordReadinessMetric (ctx , obj )
176
+ r .Metrics .RecordReadiness (ctx , obj )
177
177
r .Metrics .RecordDuration (ctx , obj , start )
178
178
}()
179
179
@@ -238,7 +238,7 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, obj *sourcev1.G
238
238
func (r * GitRepositoryReconciler ) reconcileStorage (ctx context.Context , obj * sourcev1.GitRepository ) (ctrl.Result , error ) {
239
239
// Garbage collect previous advertised artifact(s) from storage
240
240
if err := r .garbageCollect (obj ); err != nil {
241
- r .Events .Eventf (ctx , obj , nil , events .EventSeverityError , "GarbageCollectionFailed" , "Garbage collection failed: %s" , err )
241
+ r .Events .Eventf (ctx , obj , events .EventSeverityError , "GarbageCollectionFailed" , "Garbage collection failed: %s" , err )
242
242
}
243
243
244
244
// Determine if the advertised artifact is still in storage
@@ -291,7 +291,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, obj *sour
291
291
var secret corev1.Secret
292
292
if err = r .Client .Get (ctx , name , & secret ); err != nil {
293
293
conditions .MarkFalse (obj , sourcev1 .SourceAvailableCondition , sourcev1 .AuthenticationFailedReason , "Failed to get secret %s: %s" , name .String (), err .Error ())
294
- r .Events .Event (ctx , obj , nil , events .EventSeverityError , sourcev1 .AuthenticationFailedReason , conditions .Get (obj , sourcev1 .SourceAvailableCondition ).Message )
294
+ r .Events .Event (ctx , obj , events .EventSeverityError , sourcev1 .AuthenticationFailedReason , conditions .Get (obj , sourcev1 .SourceAvailableCondition ).Message )
295
295
// Return transient errors but wait for next interval on not found
296
296
return ctrl.Result {RequeueAfter : obj .Spec .Interval .Duration }, client .IgnoreNotFound (err )
297
297
}
@@ -300,7 +300,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, obj *sour
300
300
auth , err = authStrategy .Method (secret )
301
301
if err != nil {
302
302
conditions .MarkFalse (obj , sourcev1 .SourceAvailableCondition , sourcev1 .AuthenticationFailedReason , "Failed to configure auth strategy: %s" , err )
303
- r .Events .Event (ctx , obj , nil , events .EventSeverityError , sourcev1 .AuthenticationFailedReason , conditions .Get (obj , sourcev1 .SourceAvailableCondition ).Message )
303
+ r .Events .Event (ctx , obj , events .EventSeverityError , sourcev1 .AuthenticationFailedReason , conditions .Get (obj , sourcev1 .SourceAvailableCondition ).Message )
304
304
// Return err as the content of the secret may change
305
305
return ctrl.Result {}, err
306
306
}
@@ -313,7 +313,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, obj *sour
313
313
})
314
314
if err != nil {
315
315
conditions .MarkFalse (obj , sourcev1 .SourceAvailableCondition , sourcev1 .GitOperationFailedReason , "Failed to configure checkout strategy: %s" , err )
316
- r .Events .Event (ctx , obj , nil , events .EventSeverityError , sourcev1 .AuthenticationFailedReason , conditions .Get (obj , sourcev1 .SourceAvailableCondition ).Message )
316
+ r .Events .Event (ctx , obj , events .EventSeverityError , sourcev1 .AuthenticationFailedReason , conditions .Get (obj , sourcev1 .SourceAvailableCondition ).Message )
317
317
// Do not return err as recovery without changes is impossible
318
318
return ctrl.Result {}, nil
319
319
}
@@ -324,7 +324,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, obj *sour
324
324
commit , revision , err := checkoutStrategy .Checkout (gitCtx , dir , obj .Spec .URL , auth )
325
325
if err != nil {
326
326
conditions .MarkFalse (obj , sourcev1 .SourceAvailableCondition , sourcev1 .GitOperationFailedReason , "Failed to checkout and determine HEAD revision: %s" , err )
327
- r .Events .Eventf (ctx , obj , nil , events .EventSeverityError , "GitCheckoutFailed" , conditions .Get (obj , sourcev1 .SourceAvailableCondition ).Message )
327
+ r .Events .Eventf (ctx , obj , events .EventSeverityError , "GitCheckoutFailed" , conditions .Get (obj , sourcev1 .SourceAvailableCondition ).Message )
328
328
// Coin flip on transient or persistent error, requeue
329
329
// TODO(hidde): likely better to detect the err type
330
330
return ctrl.Result {}, err
@@ -399,14 +399,14 @@ func (r *GitRepositoryReconciler) reconcileArtifact(ctx context.Context, obj *so
399
399
obj .Status .Artifact = artifact .DeepCopy ()
400
400
obj .Status .IncludedArtifacts = includes
401
401
conditions .MarkTrue (obj , sourcev1 .ArtifactAvailableCondition , "ArchivedArtifact" , "Compressed source to artifact with revision %s" , artifact .Revision )
402
- r .Events .Eventf (ctx , obj , map [string ]string {
402
+ r .Events .EventWithMetaf (ctx , obj , map [string ]string {
403
403
"revision" : obj .GetArtifact ().Revision ,
404
404
}, events .EventSeverityInfo , sourcev1 .GitOperationSucceedReason , conditions .Get (obj , sourcev1 .ArtifactAvailableCondition ).Message )
405
405
406
406
// Update symlink on a "best effort" basis
407
407
url , err := r .Storage .Symlink (artifact , "latest.tar.gz" )
408
408
if err != nil {
409
- r .Events .Eventf (ctx , obj , nil , events .EventSeverityError , sourcev1 .StorageOperationFailedReason , "Failed to update status URL symlink: %s" , err )
409
+ r .Events .Eventf (ctx , obj , events .EventSeverityError , sourcev1 .StorageOperationFailedReason , "Failed to update status URL symlink: %s" , err )
410
410
}
411
411
if url != "" {
412
412
obj .Status .URL = url
@@ -475,7 +475,7 @@ func (r *GitRepositoryReconciler) reconcileInclude(ctx context.Context, obj *sou
475
475
func (r * GitRepositoryReconciler ) reconcileDelete (ctx context.Context , obj * sourcev1.GitRepository ) (ctrl.Result , error ) {
476
476
// Garbage collect the resource's artifacts
477
477
if err := r .garbageCollect (obj ); err != nil {
478
- r .Events .Eventf (ctx , obj , nil , events .EventSeverityError , "GarbageCollectionFailed" , "Garbage collection for deleted resource failed: %s" , err )
478
+ r .Events .Eventf (ctx , obj , events .EventSeverityError , "GarbageCollectionFailed" , "Garbage collection for deleted resource failed: %s" , err )
479
479
// Return the error so we retry the failed garbage collection
480
480
return ctrl.Result {}, err
481
481
}
0 commit comments