Skip to content

Commit 8e14ed8

Browse files
committed
Remove unused functions and function arguments
Signed-off-by: Matheus Pimenta <[email protected]>
1 parent 7a5b853 commit 8e14ed8

File tree

8 files changed

+19
-55
lines changed

8 files changed

+19
-55
lines changed

internal/controller/bucket_controller.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,7 @@ type bucketCredentials struct {
175175
// executed serially to perform the complete reconcile of the object.
176176
type bucketReconcileFunc func(ctx context.Context, sp *patch.SerialPatcher, obj *sourcev1.Bucket, index *index.Digester, dir string) (sreconcile.Result, error)
177177

178-
func (r *BucketReconciler) SetupWithManager(mgr ctrl.Manager) error {
179-
return r.SetupWithManagerAndOptions(mgr, BucketReconcilerOptions{})
180-
}
181-
182-
func (r *BucketReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts BucketReconcilerOptions) error {
178+
func (r *BucketReconciler) SetupWithManager(mgr ctrl.Manager, opts BucketReconcilerOptions) error {
183179
r.patchOptions = getPatchOptions(bucketReadyCondition.Owned, r.ControllerName)
184180

185181
return ctrl.NewControllerManagedBy(mgr).

internal/controller/common_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ func waitForSourceReadyWithArtifact(ctx context.Context, g *WithT, obj condition
6969
waitForSourceReady(ctx, g, obj, true)
7070
}
7171

72-
// waitForSourceReadyWithoutArtifact is a generic test helper to wait for an object
73-
// to be ready of any source kind that don't have artifact in status when ready.
74-
func waitForSourceReadyWithoutArtifact(ctx context.Context, g *WithT, obj conditions.Setter) {
75-
g.THelper()
76-
waitForSourceReady(ctx, g, obj, false)
77-
}
78-
7972
// waitForSourceReady is a generic test helper to wait for an object to be
8073
// ready of any source kind.
8174
func waitForSourceReady(ctx context.Context, g *WithT, obj conditions.Setter, withArtifact bool) {
@@ -116,14 +109,6 @@ func testSuspendedObjectDeleteWithArtifact(ctx context.Context, g *WithT, obj co
116109
testSuspendedObjectDelete(ctx, g, obj, true)
117110
}
118111

119-
// testSuspendedObjectDeleteWithoutArtifact is a generic test helper to test if
120-
// a suspended object can be deleted for objects that don't have artifact in
121-
// status when ready.
122-
func testSuspendedObjectDeleteWithoutArtifact(ctx context.Context, g *WithT, obj conditions.Setter) {
123-
g.THelper()
124-
testSuspendedObjectDelete(ctx, g, obj, false)
125-
}
126-
127112
// testSuspendedObjectDelete is a generic test helper to test if a suspended
128113
// object can be deleted.
129114
func testSuspendedObjectDelete(ctx context.Context, g *WithT, obj conditions.Setter, withArtifact bool) {

internal/controller/gitrepository_controller.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,7 @@ type GitRepositoryReconcilerOptions struct {
151151
// v1.GitRepository (sub)reconcile functions.
152152
type gitRepositoryReconcileFunc func(ctx context.Context, sp *patch.SerialPatcher, obj *sourcev1.GitRepository, commit *git.Commit, includes *artifactSet, dir string) (sreconcile.Result, error)
153153

154-
func (r *GitRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error {
155-
return r.SetupWithManagerAndOptions(mgr, GitRepositoryReconcilerOptions{})
156-
}
157-
158-
func (r *GitRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts GitRepositoryReconcilerOptions) error {
154+
func (r *GitRepositoryReconciler) SetupWithManager(mgr ctrl.Manager, opts GitRepositoryReconcilerOptions) error {
159155
r.patchOptions = getPatchOptions(gitRepositoryReadyCondition.Owned, r.ControllerName)
160156

161157
r.requeueDependency = opts.DependencyRequeueInterval
@@ -328,7 +324,7 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Seria
328324
func (r *GitRepositoryReconciler) notify(ctx context.Context, oldObj, newObj *sourcev1.GitRepository, commit git.Commit, res sreconcile.Result, resErr error) {
329325
// Notify successful reconciliation for new artifact, no-op reconciliation
330326
// and recovery from any failure.
331-
if r.shouldNotify(oldObj, newObj, res, resErr) {
327+
if r.shouldNotify(newObj, res, resErr) {
332328
annotations := map[string]string{
333329
fmt.Sprintf("%s/%s", sourcev1.GroupVersion.Group, eventv1.MetaRevisionKey): newObj.Status.Artifact.Revision,
334330
fmt.Sprintf("%s/%s", sourcev1.GroupVersion.Group, eventv1.MetaDigestKey): newObj.Status.Artifact.Digest,
@@ -362,7 +358,7 @@ func (r *GitRepositoryReconciler) notify(ctx context.Context, oldObj, newObj *so
362358
// notification should be sent. It decides about the final informational
363359
// notifications after the reconciliation. Failure notification and in-line
364360
// notifications are not handled here.
365-
func (r *GitRepositoryReconciler) shouldNotify(oldObj, newObj *sourcev1.GitRepository, res sreconcile.Result, resErr error) bool {
361+
func (r *GitRepositoryReconciler) shouldNotify(newObj *sourcev1.GitRepository, res sreconcile.Result, resErr error) bool {
366362
// Notify for successful reconciliation.
367363
if resErr == nil && res == sreconcile.ResultSuccess && newObj.Status.Artifact != nil {
368364
return true
@@ -595,7 +591,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
595591
conditions.Delete(obj, sourcev1.FetchFailedCondition)
596592

597593
// Validate sparse checkout paths after successful checkout.
598-
if err := r.validateSparseCheckoutPaths(ctx, obj, dir); err != nil {
594+
if err := r.validateSparseCheckoutPaths(obj, dir); err != nil {
599595
e := serror.NewGeneric(
600596
fmt.Errorf("failed to sparse checkout directories : %w", err),
601597
sourcev1.GitOperationFailedReason,
@@ -1302,7 +1298,7 @@ func gitContentConfigChanged(obj *sourcev1.GitRepository, includes *artifactSet)
13021298
}
13031299

13041300
// validateSparseCheckoutPaths checks if the sparse checkout paths exist in the cloned repository.
1305-
func (r *GitRepositoryReconciler) validateSparseCheckoutPaths(ctx context.Context, obj *sourcev1.GitRepository, dir string) error {
1301+
func (r *GitRepositoryReconciler) validateSparseCheckoutPaths(obj *sourcev1.GitRepository, dir string) error {
13061302
if obj.Spec.SparseCheckout != nil {
13071303
for _, path := range obj.Spec.SparseCheckout {
13081304
fullPath := filepath.Join(dir, path)

internal/controller/helmchart_controller.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ type HelmChartReconciler struct {
142142
patchOptions []patch.Option
143143
}
144144

145-
func (r *HelmChartReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
146-
return r.SetupWithManagerAndOptions(ctx, mgr, HelmChartReconcilerOptions{})
147-
}
148-
149145
type HelmChartReconcilerOptions struct {
150146
RateLimiter workqueue.TypedRateLimiter[reconcile.Request]
151147
}
@@ -173,7 +169,7 @@ const (
173169
indexKeyHelmChartSource = ".metadata.helmChartSource"
174170
)
175171

176-
func (r *HelmChartReconciler) SetupWithManagerAndOptions(ctx context.Context, mgr ctrl.Manager, opts HelmChartReconcilerOptions) error {
172+
func (r *HelmChartReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opts HelmChartReconcilerOptions) error {
177173
r.patchOptions = getPatchOptions(helmChartReadyCondition.Owned, r.ControllerName)
178174

179175
if err := mgr.GetCache().IndexField(ctx, &sourcev1.HelmRepository{}, indexKeyHelmRepositoryURL,

internal/controller/helmrepository_controller.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,7 @@ type HelmRepositoryReconcilerOptions struct {
129129
// object.
130130
type helmRepositoryReconcileFunc func(ctx context.Context, sp *patch.SerialPatcher, obj *sourcev1.HelmRepository, artifact *meta.Artifact, repo *repository.ChartRepository) (sreconcile.Result, error)
131131

132-
func (r *HelmRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error {
133-
return r.SetupWithManagerAndOptions(mgr, HelmRepositoryReconcilerOptions{})
134-
}
135-
136-
func (r *HelmRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts HelmRepositoryReconcilerOptions) error {
132+
func (r *HelmRepositoryReconciler) SetupWithManager(mgr ctrl.Manager, opts HelmRepositoryReconcilerOptions) error {
137133
r.patchOptions = getPatchOptions(helmRepositoryReadyCondition.Owned, r.ControllerName)
138134

139135
return ctrl.NewControllerManagedBy(mgr).

internal/controller/ocirepository_controller.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,7 @@ type OCIRepositoryReconcilerOptions struct {
153153
RateLimiter workqueue.TypedRateLimiter[reconcile.Request]
154154
}
155155

156-
// SetupWithManager sets up the controller with the Manager.
157-
func (r *OCIRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error {
158-
return r.SetupWithManagerAndOptions(mgr, OCIRepositoryReconcilerOptions{})
159-
}
160-
161-
func (r *OCIRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts OCIRepositoryReconcilerOptions) error {
156+
func (r *OCIRepositoryReconciler) SetupWithManager(mgr ctrl.Manager, opts OCIRepositoryReconcilerOptions) error {
162157
r.patchOptions = getPatchOptions(ociRepositoryReadyCondition.Owned, r.ControllerName)
163158

164159
r.requeueDependency = opts.DependencyRequeueInterval

internal/controller/suite_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func TestMain(m *testing.M) {
319319
EventRecorder: record.NewFakeRecorder(32),
320320
Metrics: testMetricsH,
321321
Storage: testStorage,
322-
}).SetupWithManagerAndOptions(testEnv, GitRepositoryReconcilerOptions{
322+
}).SetupWithManager(testEnv, GitRepositoryReconcilerOptions{
323323
RateLimiter: controller.GetDefaultRateLimiter(),
324324
}); err != nil {
325325
panic(fmt.Sprintf("Failed to start GitRepositoryReconciler: %v", err))
@@ -330,7 +330,7 @@ func TestMain(m *testing.M) {
330330
EventRecorder: record.NewFakeRecorder(32),
331331
Metrics: testMetricsH,
332332
Storage: testStorage,
333-
}).SetupWithManagerAndOptions(testEnv, BucketReconcilerOptions{
333+
}).SetupWithManager(testEnv, BucketReconcilerOptions{
334334
RateLimiter: controller.GetDefaultRateLimiter(),
335335
}); err != nil {
336336
panic(fmt.Sprintf("Failed to start BucketReconciler: %v", err))
@@ -344,7 +344,7 @@ func TestMain(m *testing.M) {
344344
EventRecorder: record.NewFakeRecorder(32),
345345
Metrics: testMetricsH,
346346
Storage: testStorage,
347-
}).SetupWithManagerAndOptions(testEnv, OCIRepositoryReconcilerOptions{
347+
}).SetupWithManager(testEnv, OCIRepositoryReconcilerOptions{
348348
RateLimiter: controller.GetDefaultRateLimiter(),
349349
}); err != nil {
350350
panic(fmt.Sprintf("Failed to start OCIRepositoryReconciler: %v", err))
@@ -359,7 +359,7 @@ func TestMain(m *testing.M) {
359359
Cache: testCache,
360360
TTL: 1 * time.Second,
361361
CacheRecorder: cacheRecorder,
362-
}).SetupWithManagerAndOptions(testEnv, HelmRepositoryReconcilerOptions{
362+
}).SetupWithManager(testEnv, HelmRepositoryReconcilerOptions{
363363
RateLimiter: controller.GetDefaultRateLimiter(),
364364
}); err != nil {
365365
panic(fmt.Sprintf("Failed to start HelmRepositoryReconciler: %v", err))
@@ -374,7 +374,7 @@ func TestMain(m *testing.M) {
374374
Cache: testCache,
375375
TTL: 1 * time.Second,
376376
CacheRecorder: cacheRecorder,
377-
}).SetupWithManagerAndOptions(ctx, testEnv, HelmChartReconcilerOptions{
377+
}).SetupWithManager(ctx, testEnv, HelmChartReconcilerOptions{
378378
RateLimiter: controller.GetDefaultRateLimiter(),
379379
}); err != nil {
380380
panic(fmt.Sprintf("Failed to start HelmChartReconciler: %v", err))

main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func main() {
232232
Storage: storage,
233233
ControllerName: controllerName,
234234
TokenCache: tokenCache,
235-
}).SetupWithManagerAndOptions(mgr, controller.GitRepositoryReconcilerOptions{
235+
}).SetupWithManager(mgr, controller.GitRepositoryReconcilerOptions{
236236
DependencyRequeueInterval: requeueDependency,
237237
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
238238
}); err != nil {
@@ -250,7 +250,7 @@ func main() {
250250
Cache: helmIndexCache,
251251
TTL: helmIndexCacheItemTTL,
252252
CacheRecorder: cacheRecorder,
253-
}).SetupWithManagerAndOptions(mgr, controller.HelmRepositoryReconcilerOptions{
253+
}).SetupWithManager(mgr, controller.HelmRepositoryReconcilerOptions{
254254
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
255255
}); err != nil {
256256
setupLog.Error(err, "unable to create controller", "controller", sourcev1.HelmRepositoryKind)
@@ -267,7 +267,7 @@ func main() {
267267
Cache: helmIndexCache,
268268
TTL: helmIndexCacheItemTTL,
269269
CacheRecorder: cacheRecorder,
270-
}).SetupWithManagerAndOptions(ctx, mgr, controller.HelmChartReconcilerOptions{
270+
}).SetupWithManager(ctx, mgr, controller.HelmChartReconcilerOptions{
271271
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
272272
}); err != nil {
273273
setupLog.Error(err, "unable to create controller", "controller", sourcev1.HelmChartKind)
@@ -281,7 +281,7 @@ func main() {
281281
Storage: storage,
282282
ControllerName: controllerName,
283283
TokenCache: tokenCache,
284-
}).SetupWithManagerAndOptions(mgr, controller.BucketReconcilerOptions{
284+
}).SetupWithManager(mgr, controller.BucketReconcilerOptions{
285285
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
286286
}); err != nil {
287287
setupLog.Error(err, "unable to create controller", "controller", sourcev1.BucketKind)
@@ -295,7 +295,7 @@ func main() {
295295
ControllerName: controllerName,
296296
TokenCache: tokenCache,
297297
Metrics: metrics,
298-
}).SetupWithManagerAndOptions(mgr, controller.OCIRepositoryReconcilerOptions{
298+
}).SetupWithManager(mgr, controller.OCIRepositoryReconcilerOptions{
299299
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
300300
}); err != nil {
301301
setupLog.Error(err, "unable to create controller", "controller", sourcev1.OCIRepositoryKind)

0 commit comments

Comments
 (0)