@@ -25,6 +25,7 @@ import (
25
25
"time"
26
26
27
27
securejoin "github.com/cyphar/filepath-securejoin"
28
+ "github.com/fluxcd/pkg/runtime/logger"
28
29
corev1 "k8s.io/api/core/v1"
29
30
apierrors "k8s.io/apimachinery/pkg/api/errors"
30
31
"k8s.io/apimachinery/pkg/runtime"
@@ -41,16 +42,17 @@ import (
41
42
"github.com/fluxcd/pkg/apis/meta"
42
43
"github.com/fluxcd/pkg/runtime/conditions"
43
44
helper "github.com/fluxcd/pkg/runtime/controller"
45
+ "github.com/fluxcd/pkg/runtime/events"
44
46
"github.com/fluxcd/pkg/runtime/patch"
45
47
"github.com/fluxcd/pkg/runtime/predicates"
46
- "github.com/fluxcd/source-controller/pkg/sourceignore"
47
48
48
49
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
49
50
serror "github.com/fluxcd/source-controller/internal/error"
50
51
sreconcile "github.com/fluxcd/source-controller/internal/reconcile"
51
52
"github.com/fluxcd/source-controller/internal/util"
52
53
"github.com/fluxcd/source-controller/pkg/git"
53
54
"github.com/fluxcd/source-controller/pkg/git/strategy"
55
+ "github.com/fluxcd/source-controller/pkg/sourceignore"
54
56
)
55
57
56
58
// Status conditions owned by the GitRepository reconciler.
@@ -139,7 +141,7 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
139
141
140
142
// Return early if the object is suspended
141
143
if obj .Spec .Suspend {
142
- log .Info ("Reconciliation is suspended for this object" )
144
+ log .Info ("reconciliation is suspended for this object" )
143
145
return ctrl.Result {}, nil
144
146
}
145
147
@@ -308,7 +310,7 @@ func (r *GitRepositoryReconciler) reconcileStorage(ctx context.Context, obj *sou
308
310
// If both the checkout and signature verification are successful, the given artifact pointer is set to a new artifact
309
311
// with the available metadata.
310
312
func (r * GitRepositoryReconciler ) reconcileSource (ctx context.Context ,
311
- obj * sourcev1.GitRepository , artifact * sourcev1.Artifact , includes * artifactSet , dir string ) (sreconcile.Result , error ) {
313
+ obj * sourcev1.GitRepository , artifact * sourcev1.Artifact , _ * artifactSet , dir string ) (sreconcile.Result , error ) {
312
314
// Configure authentication strategy to access the source
313
315
var authOpts * git.AuthOptions
314
316
var err error
@@ -378,8 +380,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
378
380
// Coin flip on transient or persistent error, return error and hope for the best
379
381
return sreconcile .ResultEmpty , e
380
382
}
381
- r .eventLogf (ctx , obj , corev1 .EventTypeNormal , sourcev1 .GitOperationSucceedReason ,
382
- "cloned repository '%s' and checked out revision '%s'" , obj .Spec .URL , commit .String ())
383
+ ctrl .LoggerFrom (ctx ).V (logger .DebugLevel ).Info ("git repository checked out" , "url" , obj .Spec .URL , "revision" , commit .String ())
383
384
conditions .Delete (obj , sourcev1 .FetchFailedCondition )
384
385
385
386
// Verify commit signature
@@ -420,7 +421,7 @@ func (r *GitRepositoryReconciler) reconcileArtifact(ctx context.Context, obj *so
420
421
421
422
// The artifact is up-to-date
422
423
if obj .GetArtifact ().HasRevision (artifact .Revision ) && ! includes .Diff (obj .Status .IncludedArtifacts ) {
423
- r . eventLogf (ctx , obj , corev1 . EventTypeNormal , meta . SucceededReason , "already up to date, current revision '%s' " , artifact .Revision )
424
+ ctrl . LoggerFrom (ctx ). Info ( "artifact up-to- date" , " revision" , artifact .Revision )
424
425
return sreconcile .ResultSuccess , nil
425
426
}
426
427
@@ -492,7 +493,7 @@ func (r *GitRepositoryReconciler) reconcileArtifact(ctx context.Context, obj *so
492
493
url , err := r .Storage .Symlink (* artifact , "latest.tar.gz" )
493
494
if err != nil {
494
495
r .eventLogf (ctx , obj , corev1 .EventTypeWarning , sourcev1 .StorageOperationFailedReason ,
495
- "Failed to update status URL symlink: %s" , err )
496
+ "failed to update status URL symlink: %s" , err )
496
497
}
497
498
if url != "" {
498
499
obj .Status .URL = url
@@ -506,7 +507,7 @@ func (r *GitRepositoryReconciler) reconcileArtifact(ctx context.Context, obj *so
506
507
// If an include is unavailable, it marks the object with v1beta1.IncludeUnavailableCondition and returns early.
507
508
// If the copy operations are successful, it deletes the v1beta1.IncludeUnavailableCondition from the object.
508
509
// If the artifactSet differs from the current set, it marks the object with v1beta1.ArtifactOutdatedCondition.
509
- func (r * GitRepositoryReconciler ) reconcileInclude (ctx context.Context , obj * sourcev1.GitRepository , artifact * sourcev1.Artifact , includes * artifactSet , dir string ) (sreconcile.Result , error ) {
510
+ func (r * GitRepositoryReconciler ) reconcileInclude (ctx context.Context , obj * sourcev1.GitRepository , _ * sourcev1.Artifact , includes * artifactSet , dir string ) (sreconcile.Result , error ) {
510
511
artifacts := make (artifactSet , len (obj .Spec .Include ))
511
512
for i , incl := range obj .Spec .Include {
512
513
// Do this first as it is much cheaper than copy operations
@@ -544,7 +545,7 @@ func (r *GitRepositoryReconciler) reconcileInclude(ctx context.Context, obj *sou
544
545
// Copy artifact (sub)contents to configured directory
545
546
if err := r .Storage .CopyToPath (dep .GetArtifact (), incl .GetFromPath (), toPath ); err != nil {
546
547
e := & serror.Event {
547
- Err : fmt .Errorf ("Failed to copy '%s' include from %s to %s: %w" , incl .GitRepositoryRef .Name , incl .GetFromPath (), incl .GetToPath (), err ),
548
+ Err : fmt .Errorf ("failed to copy '%s' include from %s to %s: %w" , incl .GitRepositoryRef .Name , incl .GetFromPath (), incl .GetToPath (), err ),
548
549
Reason : "CopyFailure" ,
549
550
}
550
551
conditions .MarkTrue (obj , sourcev1 .IncludeUnavailableCondition , "CopyFailure" , e .Err .Error ())
@@ -623,7 +624,7 @@ func (r *GitRepositoryReconciler) verifyCommitSignature(ctx context.Context, obj
623
624
624
625
conditions .MarkTrue (obj , sourcev1 .SourceVerifiedCondition , meta .SucceededReason ,
625
626
"verified signature of commit '%s'" , commit .Hash .String ())
626
- r .eventLogf (ctx , obj , corev1 . EventTypeNormal , "VerifiedCommit" ,
627
+ r .eventLogf (ctx , obj , events . EventTypeTrace , "VerifiedCommit" ,
627
628
"verified signature of commit '%s'" , commit .Hash .String ())
628
629
return sreconcile .ResultSuccess , nil
629
630
}
@@ -641,7 +642,7 @@ func (r *GitRepositoryReconciler) garbageCollect(ctx context.Context, obj *sourc
641
642
}
642
643
obj .Status .Artifact = nil
643
644
// TODO(hidde): we should only push this event if we actually garbage collected something
644
- r .eventLogf (ctx , obj , corev1 . EventTypeNormal , "GarbageCollectionSucceeded" ,
645
+ r .eventLogf (ctx , obj , events . EventTypeTrace , "GarbageCollectionSucceeded" ,
645
646
"garbage collected artifacts for deleted resource" )
646
647
return nil
647
648
}
@@ -652,7 +653,7 @@ func (r *GitRepositoryReconciler) garbageCollect(ctx context.Context, obj *sourc
652
653
}
653
654
}
654
655
// TODO(hidde): we should only push this event if we actually garbage collected something
655
- r .eventLogf (ctx , obj , corev1 . EventTypeNormal , "GarbageCollectionSucceeded" ,
656
+ r .eventLogf (ctx , obj , events . EventTypeTrace , "GarbageCollectionSucceeded" ,
656
657
"garbage collected old artifacts" )
657
658
}
658
659
return nil
0 commit comments