@@ -52,7 +52,6 @@ import (
52
52
rreconcile "github.com/fluxcd/pkg/runtime/reconcile"
53
53
"github.com/fluxcd/pkg/sourceignore"
54
54
55
- bucketv1 "github.com/fluxcd/source-controller/api/v1"
56
55
sourcev1 "github.com/fluxcd/source-controller/api/v1"
57
56
intdigest "github.com/fluxcd/source-controller/internal/digest"
58
57
serror "github.com/fluxcd/source-controller/internal/error"
@@ -159,7 +158,7 @@ type BucketProvider interface {
159
158
// bucketReconcileFunc is the function type for all the v1beta2.Bucket
160
159
// (sub)reconcile functions. The type implementations are grouped and
161
160
// executed serially to perform the complete reconcile of the object.
162
- type bucketReconcileFunc func (ctx context.Context , sp * patch.SerialPatcher , obj * bucketv1 .Bucket , index * index.Digester , dir string ) (sreconcile.Result , error )
161
+ type bucketReconcileFunc func (ctx context.Context , sp * patch.SerialPatcher , obj * sourcev1 .Bucket , index * index.Digester , dir string ) (sreconcile.Result , error )
163
162
164
163
func (r * BucketReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
165
164
return r .SetupWithManagerAndOptions (mgr , BucketReconcilerOptions {})
@@ -169,7 +168,7 @@ func (r *BucketReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts Buc
169
168
r .patchOptions = getPatchOptions (bucketReadyCondition .Owned , r .ControllerName )
170
169
171
170
return ctrl .NewControllerManagedBy (mgr ).
172
- For (& bucketv1 .Bucket {}).
171
+ For (& sourcev1 .Bucket {}).
173
172
WithEventFilter (predicate .Or (predicate.GenerationChangedPredicate {}, predicates.ReconcileRequestedPredicate {})).
174
173
WithOptions (controller.Options {
175
174
RateLimiter : opts .RateLimiter ,
@@ -182,7 +181,7 @@ func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
182
181
log := ctrl .LoggerFrom (ctx )
183
182
184
183
// Fetch the Bucket
185
- obj := & bucketv1 .Bucket {}
184
+ obj := & sourcev1 .Bucket {}
186
185
if err := r .Get (ctx , req .NamespacedName , obj ); err != nil {
187
186
return ctrl.Result {}, client .IgnoreNotFound (err )
188
187
}
@@ -255,7 +254,7 @@ func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
255
254
// reconcile iterates through the bucketReconcileFunc tasks for the
256
255
// object. It returns early on the first call that returns
257
256
// reconcile.ResultRequeue, or produces an error.
258
- func (r * BucketReconciler ) reconcile (ctx context.Context , sp * patch.SerialPatcher , obj * bucketv1 .Bucket , reconcilers []bucketReconcileFunc ) (sreconcile.Result , error ) {
257
+ func (r * BucketReconciler ) reconcile (ctx context.Context , sp * patch.SerialPatcher , obj * sourcev1 .Bucket , reconcilers []bucketReconcileFunc ) (sreconcile.Result , error ) {
259
258
oldObj := obj .DeepCopy ()
260
259
261
260
rreconcile .ProgressiveStatus (false , obj , meta .ProgressingReason , "reconciliation in progress" )
@@ -326,7 +325,7 @@ func (r *BucketReconciler) reconcile(ctx context.Context, sp *patch.SerialPatche
326
325
}
327
326
328
327
// notify emits notification related to the reconciliation.
329
- func (r * BucketReconciler ) notify (ctx context.Context , oldObj , newObj * bucketv1 .Bucket , index * index.Digester , res sreconcile.Result , resErr error ) {
328
+ func (r * BucketReconciler ) notify (ctx context.Context , oldObj , newObj * sourcev1 .Bucket , index * index.Digester , res sreconcile.Result , resErr error ) {
330
329
// Notify successful reconciliation for new artifact and recovery from any
331
330
// failure.
332
331
if resErr == nil && res == sreconcile .ResultSuccess && newObj .Status .Artifact != nil {
@@ -364,7 +363,7 @@ func (r *BucketReconciler) notify(ctx context.Context, oldObj, newObj *bucketv1.
364
363
// condition is added.
365
364
// The hostname of any URL in the Status of the object are updated, to ensure
366
365
// they match the Storage server hostname of current runtime.
367
- func (r * BucketReconciler ) reconcileStorage (ctx context.Context , sp * patch.SerialPatcher , obj * bucketv1 .Bucket , _ * index.Digester , _ string ) (sreconcile.Result , error ) {
366
+ func (r * BucketReconciler ) reconcileStorage (ctx context.Context , sp * patch.SerialPatcher , obj * sourcev1 .Bucket , _ * index.Digester , _ string ) (sreconcile.Result , error ) {
368
367
// Garbage collect previous advertised artifact(s) from storage
369
368
_ = r .garbageCollect (ctx , obj )
370
369
@@ -423,7 +422,7 @@ func (r *BucketReconciler) reconcileStorage(ctx context.Context, sp *patch.Seria
423
422
// When a SecretRef is defined, it attempts to fetch the Secret before calling
424
423
// the provider. If this fails, it records v1beta2.FetchFailedCondition=True on
425
424
// the object and returns early.
426
- func (r * BucketReconciler ) reconcileSource (ctx context.Context , sp * patch.SerialPatcher , obj * bucketv1 .Bucket , index * index.Digester , dir string ) (sreconcile.Result , error ) {
425
+ func (r * BucketReconciler ) reconcileSource (ctx context.Context , sp * patch.SerialPatcher , obj * sourcev1 .Bucket , index * index.Digester , dir string ) (sreconcile.Result , error ) {
427
426
secret , err := r .getSecret (ctx , obj .Spec .SecretRef , obj .GetNamespace ())
428
427
if err != nil {
429
428
e := serror .NewGeneric (err , sourcev1 .AuthenticationFailedReason )
@@ -441,7 +440,7 @@ func (r *BucketReconciler) reconcileSource(ctx context.Context, sp *patch.Serial
441
440
// Construct provider client
442
441
var provider BucketProvider
443
442
switch obj .Spec .Provider {
444
- case bucketv1 .BucketProviderGoogle :
443
+ case sourcev1 .BucketProviderGoogle :
445
444
if err = gcp .ValidateSecret (secret ); err != nil {
446
445
e := serror .NewGeneric (err , sourcev1 .AuthenticationFailedReason )
447
446
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , "%s" , e )
@@ -459,7 +458,7 @@ func (r *BucketReconciler) reconcileSource(ctx context.Context, sp *patch.Serial
459
458
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , "%s" , e )
460
459
return sreconcile .ResultEmpty , e
461
460
}
462
- case bucketv1 .BucketProviderAzure :
461
+ case sourcev1 .BucketProviderAzure :
463
462
if err = azure .ValidateSecret (secret ); err != nil {
464
463
e := serror .NewGeneric (err , sourcev1 .AuthenticationFailedReason )
465
464
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , "%s" , e )
@@ -545,7 +544,7 @@ func (r *BucketReconciler) reconcileSource(ctx context.Context, sp *patch.Serial
545
544
546
545
// Fetch etag index
547
546
if err = fetchEtagIndex (ctx , provider , obj , index , dir ); err != nil {
548
- e := serror .NewGeneric (err , bucketv1 .BucketOperationFailedReason )
547
+ e := serror .NewGeneric (err , sourcev1 .BucketOperationFailedReason )
549
548
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , "%s" , e )
550
549
return sreconcile .ResultEmpty , e
551
550
}
@@ -577,7 +576,7 @@ func (r *BucketReconciler) reconcileSource(ctx context.Context, sp *patch.Serial
577
576
}()
578
577
579
578
if err = fetchIndexFiles (ctx , provider , obj , index , dir ); err != nil {
580
- e := serror .NewGeneric (err , bucketv1 .BucketOperationFailedReason )
579
+ e := serror .NewGeneric (err , sourcev1 .BucketOperationFailedReason )
581
580
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , "%s" , e )
582
581
return sreconcile .ResultEmpty , e
583
582
}
@@ -596,7 +595,7 @@ func (r *BucketReconciler) reconcileSource(ctx context.Context, sp *patch.Serial
596
595
// early.
597
596
// On a successful archive, the Artifact in the Status of the object is set,
598
597
// and the symlink in the Storage is updated to its path.
599
- func (r * BucketReconciler ) reconcileArtifact (ctx context.Context , sp * patch.SerialPatcher , obj * bucketv1 .Bucket , index * index.Digester , dir string ) (sreconcile.Result , error ) {
598
+ func (r * BucketReconciler ) reconcileArtifact (ctx context.Context , sp * patch.SerialPatcher , obj * sourcev1 .Bucket , index * index.Digester , dir string ) (sreconcile.Result , error ) {
600
599
// Calculate revision
601
600
revision := index .Digest (intdigest .Canonical )
602
601
@@ -689,7 +688,7 @@ func (r *BucketReconciler) reconcileArtifact(ctx context.Context, sp *patch.Seri
689
688
// reconcileDelete handles the deletion of the object.
690
689
// It first garbage collects all Artifacts for the object from the Storage.
691
690
// Removing the finalizer from the object if successful.
692
- func (r * BucketReconciler ) reconcileDelete (ctx context.Context , obj * bucketv1 .Bucket ) (sreconcile.Result , error ) {
691
+ func (r * BucketReconciler ) reconcileDelete (ctx context.Context , obj * sourcev1 .Bucket ) (sreconcile.Result , error ) {
693
692
// Garbage collect the resource's artifacts
694
693
if err := r .garbageCollect (ctx , obj ); err != nil {
695
694
// Return the error so we retry the failed garbage collection
@@ -708,7 +707,7 @@ func (r *BucketReconciler) reconcileDelete(ctx context.Context, obj *bucketv1.Bu
708
707
// It removes all but the current Artifact from the Storage, unless the
709
708
// deletion timestamp on the object is set. Which will result in the
710
709
// removal of all Artifacts for the objects.
711
- func (r * BucketReconciler ) garbageCollect (ctx context.Context , obj * bucketv1 .Bucket ) error {
710
+ func (r * BucketReconciler ) garbageCollect (ctx context.Context , obj * sourcev1 .Bucket ) error {
712
711
if ! obj .DeletionTimestamp .IsZero () {
713
712
if deleted , err := r .Storage .RemoveAll (r .Storage .NewArtifactFor (obj .Kind , obj .GetObjectMeta (), "" , "*" )); err != nil {
714
713
return serror .NewGeneric (
@@ -776,7 +775,7 @@ func (r *BucketReconciler) getTLSConfig(ctx context.Context,
776
775
777
776
// getProxyURL attempts to fetch a proxy URL from the object's proxy secret
778
777
// reference.
779
- func (r * BucketReconciler ) getProxyURL (ctx context.Context , obj * bucketv1 .Bucket ) (* url.URL , error ) {
778
+ func (r * BucketReconciler ) getProxyURL (ctx context.Context , obj * sourcev1 .Bucket ) (* url.URL , error ) {
780
779
namespace := obj .GetNamespace ()
781
780
proxySecret , err := r .getSecret (ctx , obj .Spec .ProxySecretRef , namespace )
782
781
if err != nil || proxySecret == nil {
@@ -802,7 +801,7 @@ func (r *BucketReconciler) getProxyURL(ctx context.Context, obj *bucketv1.Bucket
802
801
803
802
// getSTSSecret attempts to fetch the secret from the object's STS secret
804
803
// reference.
805
- func (r * BucketReconciler ) getSTSSecret (ctx context.Context , obj * bucketv1 .Bucket ) (* corev1.Secret , error ) {
804
+ func (r * BucketReconciler ) getSTSSecret (ctx context.Context , obj * sourcev1 .Bucket ) (* corev1.Secret , error ) {
806
805
if obj .Spec .STS == nil {
807
806
return nil , nil
808
807
}
@@ -811,7 +810,7 @@ func (r *BucketReconciler) getSTSSecret(ctx context.Context, obj *bucketv1.Bucke
811
810
812
811
// getSTSTLSConfig attempts to fetch the certificate secret from the object's
813
812
// STS configuration.
814
- func (r * BucketReconciler ) getSTSTLSConfig (ctx context.Context , obj * bucketv1 .Bucket ) (* stdtls.Config , error ) {
813
+ func (r * BucketReconciler ) getSTSTLSConfig (ctx context.Context , obj * sourcev1 .Bucket ) (* stdtls.Config , error ) {
815
814
if obj .Spec .STS == nil {
816
815
return nil , nil
817
816
}
@@ -848,7 +847,7 @@ func (r *BucketReconciler) annotatedEventLogf(ctx context.Context,
848
847
// bucket using the given provider, while filtering them using .sourceignore
849
848
// rules. After fetching an object, the etag value in the index is updated to
850
849
// the current value to ensure accuracy.
851
- func fetchEtagIndex (ctx context.Context , provider BucketProvider , obj * bucketv1 .Bucket , index * index.Digester , tempDir string ) error {
850
+ func fetchEtagIndex (ctx context.Context , provider BucketProvider , obj * sourcev1 .Bucket , index * index.Digester , tempDir string ) error {
852
851
ctxTimeout , cancel := context .WithTimeout (ctx , obj .Spec .Timeout .Duration )
853
852
defer cancel ()
854
853
@@ -902,7 +901,7 @@ func fetchEtagIndex(ctx context.Context, provider BucketProvider, obj *bucketv1.
902
901
// using the given provider, and stores them into tempDir. It downloads in
903
902
// parallel, but limited to the maxConcurrentBucketFetches.
904
903
// Given an index is provided, the bucket is assumed to exist.
905
- func fetchIndexFiles (ctx context.Context , provider BucketProvider , obj * bucketv1 .Bucket , index * index.Digester , tempDir string ) error {
904
+ func fetchIndexFiles (ctx context.Context , provider BucketProvider , obj * sourcev1 .Bucket , index * index.Digester , tempDir string ) error {
906
905
ctxTimeout , cancel := context .WithTimeout (ctx , obj .Spec .Timeout .Duration )
907
906
defer cancel ()
908
907
0 commit comments