diff --git a/controllers/gitrepository_controller_fuzz_test.go b/controllers/gitrepository_controller_fuzz_test.go index f16779f0f..65207230a 100644 --- a/controllers/gitrepository_controller_fuzz_test.go +++ b/controllers/gitrepository_controller_fuzz_test.go @@ -59,7 +59,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "github.com/fluxcd/pkg/gittestserver" + "github.com/fluxcd/pkg/runtime/controller" "github.com/fluxcd/pkg/runtime/testenv" + sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" ) @@ -448,7 +450,9 @@ func ensureDependencies() error { utilruntime.Must((&GitRepositoryReconciler{ Client: m.GetClient(), Storage: storage, - }).SetupWithManager(m)) + }).SetupWithManagerAndOptions(m, GitRepositoryReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + })) }) return nil diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 12652f330..44c1a09ca 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -28,6 +28,8 @@ import ( "testing" "time" + "github.com/phayes/freeport" + "github.com/sirupsen/logrus" "golang.org/x/crypto/bcrypt" "helm.sh/helm/v3/pkg/getter" helmreg "helm.sh/helm/v3/pkg/registry" @@ -36,18 +38,16 @@ import ( "k8s.io/client-go/tools/record" ctrl "sigs.k8s.io/controller-runtime" - dcontext "github.com/distribution/distribution/v3/context" - "github.com/fluxcd/pkg/runtime/controller" - "github.com/fluxcd/pkg/runtime/testenv" - "github.com/fluxcd/pkg/testserver" - "github.com/phayes/freeport" - "github.com/sirupsen/logrus" - "github.com/distribution/distribution/v3/configuration" + dcontext "github.com/distribution/distribution/v3/context" dockerRegistry "github.com/distribution/distribution/v3/registry" _ "github.com/distribution/distribution/v3/registry/auth/htpasswd" _ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory" + "github.com/fluxcd/pkg/runtime/controller" + "github.com/fluxcd/pkg/runtime/testenv" + "github.com/fluxcd/pkg/testserver" + sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" "github.com/fluxcd/source-controller/internal/cache" "github.com/fluxcd/source-controller/internal/features" @@ -241,7 +241,9 @@ func TestMain(m *testing.M) { features: map[string]bool{ features.OptimizedGitClones: true, }, - }).SetupWithManager(testEnv); err != nil { + }).SetupWithManagerAndOptions(testEnv, GitRepositoryReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { panic(fmt.Sprintf("Failed to start GitRepositoryReconciler: %v", err)) } @@ -250,7 +252,9 @@ func TestMain(m *testing.M) { EventRecorder: record.NewFakeRecorder(32), Metrics: testMetricsH, Storage: testStorage, - }).SetupWithManager(testEnv); err != nil { + }).SetupWithManagerAndOptions(testEnv, BucketReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { panic(fmt.Sprintf("Failed to start BucketReconciler: %v", err)) } @@ -262,7 +266,9 @@ func TestMain(m *testing.M) { EventRecorder: record.NewFakeRecorder(32), Metrics: testMetricsH, Storage: testStorage, - }).SetupWithManager(testEnv); err != nil { + }).SetupWithManagerAndOptions(testEnv, OCIRepositoryReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { panic(fmt.Sprintf("Failed to start OCIRepositoryReconciler: %v", err)) } @@ -275,7 +281,9 @@ func TestMain(m *testing.M) { Cache: testCache, TTL: 1 * time.Second, CacheRecorder: cacheRecorder, - }).SetupWithManager(testEnv); err != nil { + }).SetupWithManagerAndOptions(testEnv, HelmRepositoryReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { panic(fmt.Sprintf("Failed to start HelmRepositoryReconciler: %v", err)) } @@ -285,7 +293,9 @@ func TestMain(m *testing.M) { Metrics: testMetricsH, Getters: testGetters, RegistryClientGenerator: registry.ClientGenerator, - }).SetupWithManager(testEnv); err != nil { + }).SetupWithManagerAndOptions(testEnv, HelmRepositoryReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { panic(fmt.Sprintf("Failed to start HelmRepositoryOCIReconciler: %v", err)) } @@ -298,8 +308,10 @@ func TestMain(m *testing.M) { Cache: testCache, TTL: 1 * time.Second, CacheRecorder: cacheRecorder, - }).SetupWithManager(testEnv); err != nil { - panic(fmt.Sprintf("Failed to start HelmRepositoryReconciler: %v", err)) + }).SetupWithManagerAndOptions(testEnv, HelmChartReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { + panic(fmt.Sprintf("Failed to start HelmChartReconciler: %v", err)) } go func() { diff --git a/go.mod b/go.mod index fbeff2217..075a4a4d4 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/fluxcd/pkg/lockedfile v0.1.0 github.com/fluxcd/pkg/masktoken v0.2.0 github.com/fluxcd/pkg/oci v0.17.0 - github.com/fluxcd/pkg/runtime v0.25.0 + github.com/fluxcd/pkg/runtime v0.26.0 github.com/fluxcd/pkg/sourceignore v0.3.0 github.com/fluxcd/pkg/ssh v0.7.0 github.com/fluxcd/pkg/testserver v0.4.0 diff --git a/go.sum b/go.sum index 000fdc538..64a3e69e5 100644 --- a/go.sum +++ b/go.sum @@ -549,8 +549,8 @@ github.com/fluxcd/pkg/masktoken v0.2.0 h1:HoSPTk4l1fz5Fevs2vVRvZGru33blfMwWSZKsH github.com/fluxcd/pkg/masktoken v0.2.0/go.mod h1:EA7GleAHL33kN6kTW06m5R3/Q26IyuGO7Ef/0CtpDI0= github.com/fluxcd/pkg/oci v0.17.0 h1:DYoT0HG3DogEmeXRif6ZzTYwAZe+iqYWP4QpsP37ZBE= github.com/fluxcd/pkg/oci v0.17.0/go.mod h1:UjxCQcdcKtog/ad9Vr2yPYjz9keNSoLdTOOiUNqCRiY= -github.com/fluxcd/pkg/runtime v0.25.0 h1:Lk5WrKDJKsayymLnnSCY/Zn77/mrlIf+skYz64suoww= -github.com/fluxcd/pkg/runtime v0.25.0/go.mod h1:I2T+HWVNzX0cxm9TgH+SVNHTwqlmEDiSke43JXsq9iY= +github.com/fluxcd/pkg/runtime v0.26.0 h1:j78f52xzpbR8xOvvemGwbGt4BLxpn9FOzim5tngOYvo= +github.com/fluxcd/pkg/runtime v0.26.0/go.mod h1:I2T+HWVNzX0cxm9TgH+SVNHTwqlmEDiSke43JXsq9iY= github.com/fluxcd/pkg/sourceignore v0.3.0 h1:pFO3hKV9ub+2SrNZPZE7xfiRhxsycRrd7JK7qB26nVw= github.com/fluxcd/pkg/sourceignore v0.3.0/go.mod h1:ak3Tve/KwVzytZ5V2yBlGGpTJ/2oQ9kcP3iuwBOAHGo= github.com/fluxcd/pkg/ssh v0.7.0 h1:FX5ky8SU9dYwbM6zEIDR3TSveLF01iyS95CtB5Ykpno=