Skip to content

Commit 84d2053

Browse files
committed
fmt + lint.
1 parent a3dc13b commit 84d2053

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

pkg/controller/controller_integration_test.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,46 +53,46 @@ var _ = Describe("controller", func() {
5353
Describe("controller", func() {
5454
// TODO(directxman12): write a whole suite of controller-client interaction tests
5555

56-
// Since all tests are run in parallel and share the same testenv, we namespace the objects
57-
// created by using a namespace per entry, and adding a watch predicate that filters by
58-
// namespace.
56+
// Since all tests are run in parallel and share the same testenv, we namespace the objects
57+
// created by using a namespace per entry, and adding a watch predicate that filters by
58+
// namespace.
5959
DescribeTable("should reconcile", func(enableWarmup bool) {
6060
By("Creating the Manager")
6161
cm, err := manager.New(cfg, manager.Options{})
6262
Expect(err).NotTo(HaveOccurred())
6363

6464
By("Creating the Controller")
6565
instance, err := controller.New(
66-
fmt.Sprintf("foo-controller-%t", enableWarmup),
67-
cm,
68-
controller.Options{
69-
Reconciler: reconcile.Func(
70-
func(_ context.Context, request reconcile.Request) (reconcile.Result, error) {
71-
reconciled <- request
72-
return reconcile.Result{}, nil
73-
}),
74-
EnableWarmup: ptr.To(enableWarmup),
75-
},
76-
)
66+
fmt.Sprintf("foo-controller-%t", enableWarmup),
67+
cm,
68+
controller.Options{
69+
Reconciler: reconcile.Func(
70+
func(_ context.Context, request reconcile.Request) (reconcile.Result, error) {
71+
reconciled <- request
72+
return reconcile.Result{}, nil
73+
}),
74+
EnableWarmup: ptr.To(enableWarmup),
75+
},
76+
)
7777
Expect(err).NotTo(HaveOccurred())
7878

79-
testNamespace := strconv.FormatBool(enableWarmup)
79+
testNamespace := strconv.FormatBool(enableWarmup)
8080

8181
By("Watching Resources")
8282
err = instance.Watch(
8383
source.Kind(cm.GetCache(), &appsv1.ReplicaSet{},
8484
handler.TypedEnqueueRequestForOwner[*appsv1.ReplicaSet](cm.GetScheme(), cm.GetRESTMapper(), &appsv1.Deployment{}),
85-
makeNamespacePredicate[*appsv1.ReplicaSet](testNamespace),
85+
makeNamespacePredicate[*appsv1.ReplicaSet](testNamespace),
8686
),
8787
)
8888
Expect(err).NotTo(HaveOccurred())
8989

9090
err = instance.Watch(
91-
source.Kind(cm.GetCache(), &appsv1.Deployment{},
92-
&handler.TypedEnqueueRequestForObject[*appsv1.Deployment]{},
93-
makeNamespacePredicate[*appsv1.Deployment](testNamespace),
94-
),
95-
)
91+
source.Kind(cm.GetCache(), &appsv1.Deployment{},
92+
&handler.TypedEnqueueRequestForObject[*appsv1.Deployment]{},
93+
makeNamespacePredicate[*appsv1.Deployment](testNamespace),
94+
),
95+
)
9696
Expect(err).NotTo(HaveOccurred())
9797

9898
err = cm.GetClient().Get(ctx, types.NamespacedName{Name: "foo"}, &corev1.Namespace{})
@@ -135,11 +135,11 @@ var _ = Describe("controller", func() {
135135
Name: "deployment-name",
136136
}}
137137

138-
By("Creating the test namespace")
139-
_, err = clientset.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{
140-
ObjectMeta: metav1.ObjectMeta{ Name: testNamespace },
141-
}, metav1.CreateOptions{})
142-
Expect(err).NotTo(HaveOccurred())
138+
By("Creating the test namespace")
139+
_, err = clientset.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{
140+
ObjectMeta: metav1.ObjectMeta{Name: testNamespace},
141+
}, metav1.CreateOptions{})
142+
Expect(err).NotTo(HaveOccurred())
143143

144144
By("Invoking Reconciling for Create")
145145
deployment, err = clientset.AppsV1().Deployments(testNamespace).Create(ctx, deployment, metav1.CreateOptions{})
@@ -202,11 +202,11 @@ var _ = Describe("controller", func() {
202202
By("Invoking Reconciling for a pod when it is created when adding watcher dynamically")
203203
// Add new watcher dynamically
204204
err = instance.Watch(
205-
source.Kind(cm.GetCache(), &corev1.Pod{},
206-
&handler.TypedEnqueueRequestForObject[*corev1.Pod]{},
207-
makeNamespacePredicate[*corev1.Pod](testNamespace),
208-
),
209-
)
205+
source.Kind(cm.GetCache(), &corev1.Pod{},
206+
&handler.TypedEnqueueRequestForObject[*corev1.Pod]{},
207+
makeNamespacePredicate[*corev1.Pod](testNamespace),
208+
),
209+
)
210210
Expect(err).NotTo(HaveOccurred())
211211

212212
pod := &corev1.Pod{
@@ -242,9 +242,9 @@ var _ = Describe("controller", func() {
242242
// makeNamespacePredicate returns a predicate that filters out all objects not in the passed in
243243
// namespace.
244244
func makeNamespacePredicate[object client.Object](namespace string) predicate.TypedPredicate[object] {
245-
return predicate.NewTypedPredicateFuncs[object](func(obj object) bool {
246-
return obj.GetNamespace() == namespace
247-
})
245+
return predicate.NewTypedPredicateFuncs[object](func(obj object) bool {
246+
return obj.GetNamespace() == namespace
247+
})
248248
}
249249

250250
func truePtr() *bool {

pkg/internal/controller/controller.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,16 @@ func (c *Controller[request]) startEventSourcesAndQueueLocked(ctx context.Contex
303303
var retErr error
304304

305305
c.didStartEventSourcesOnce.Do(func() {
306-
queue := c.NewQueue(c.Name, c.RateLimiter)
307-
if priorityQueue, isPriorityQueue := queue.(priorityqueue.PriorityQueue[request]); isPriorityQueue {
308-
c.Queue = priorityQueue
309-
} else {
310-
c.Queue = &priorityQueueWrapper[request]{TypedRateLimitingInterface: queue}
311-
}
312-
go func() {
313-
<-ctx.Done()
314-
c.Queue.ShutDown()
315-
}()
306+
queue := c.NewQueue(c.Name, c.RateLimiter)
307+
if priorityQueue, isPriorityQueue := queue.(priorityqueue.PriorityQueue[request]); isPriorityQueue {
308+
c.Queue = priorityQueue
309+
} else {
310+
c.Queue = &priorityQueueWrapper[request]{TypedRateLimitingInterface: queue}
311+
}
312+
go func() {
313+
<-ctx.Done()
314+
c.Queue.ShutDown()
315+
}()
316316

317317
errGroup := &errgroup.Group{}
318318
for _, watch := range c.startWatches {
@@ -380,7 +380,7 @@ func (c *Controller[request]) startEventSourcesAndQueueLocked(ctx context.Contex
380380
c.startWatches = nil
381381

382382
// Mark event sources as started after resetting the startWatches slice so that watches from
383-
// a new Watch() call are immediately started.
383+
// a new Watch() call are immediately started.
384384
c.startedEventSourcesAndQueue = true
385385
})
386386

pkg/internal/controller/controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ var _ = Describe("controller", func() {
404404
ctrl.startWatches = []source.TypedSource[reconcile.Request]{}
405405
err := ctrl.startEventSourcesAndQueueLocked(ctx)
406406
Expect(err).NotTo(HaveOccurred())
407-
Expect(ctrl.Queue).NotTo(BeNil())
407+
Expect(ctrl.Queue).NotTo(BeNil())
408408
})
409409

410410
It("should return an error if a source fails to start", func() {
@@ -1166,7 +1166,7 @@ var _ = Describe("controller", func() {
11661166
ctx, cancel := context.WithCancel(context.Background())
11671167
src := source.Func(func(ctx context.Context, q workqueue.TypedRateLimitingInterface[reconcile.Request]) error {
11681168
defer GinkgoRecover()
1169-
Expect(q).ToNot(BeNil())
1169+
Expect(q).ToNot(BeNil())
11701170
Expect(q).To(Equal(ctrl.Queue))
11711171

11721172
started = true
@@ -1175,7 +1175,7 @@ var _ = Describe("controller", func() {
11751175
})
11761176
Expect(ctrl.Watch(src)).To(Succeed())
11771177
Expect(ctrl.Warmup(ctx)).To(Succeed())
1178-
Expect(ctrl.Queue).ToNot(BeNil())
1178+
Expect(ctrl.Queue).ToNot(BeNil())
11791179
Expect(started).To(BeTrue())
11801180
})
11811181

0 commit comments

Comments
 (0)