@@ -29,7 +29,6 @@ import (
2929 coordinationv1client "k8s.io/client-go/kubernetes/typed/coordination/v1"
3030 "k8s.io/client-go/rest"
3131 "k8s.io/client-go/tools/leaderelection/resourcelock"
32- "k8s.io/client-go/tools/record"
3332 "k8s.io/utils/ptr"
3433 "sigs.k8s.io/controller-runtime/pkg/client"
3534
@@ -75,11 +74,11 @@ var _ = Describe("LeaseLock", func() {
7574 It ("should fail if ControllerRingName is empty" , func () {
7675 options .ControllerRingName = ""
7776
78- Expect (NewResourceLock (restConfig , nil , options )).Error ().To (MatchError ("ControllerRingName is required" ))
77+ Expect (NewResourceLock (restConfig , options )).Error ().To (MatchError ("ControllerRingName is required" ))
7978 })
8079
8180 It ("should use the configured namespace and name" , func () {
82- resourceLock , err := NewResourceLock (restConfig , nil , options )
81+ resourceLock , err := NewResourceLock (restConfig , options )
8382 Expect (err ).NotTo (HaveOccurred ())
8483
8584 leaseLock := resourceLock .(* LeaseLock )
@@ -93,7 +92,7 @@ var _ = Describe("LeaseLock", func() {
9392 hostname , err := os .Hostname ()
9493 Expect (err ).NotTo (HaveOccurred ())
9594
96- resourceLock , err := NewResourceLock (restConfig , nil , options )
95+ resourceLock , err := NewResourceLock (restConfig , options )
9796 Expect (err ).NotTo (HaveOccurred ())
9897
9998 leaseLock := resourceLock .(* LeaseLock )
@@ -104,7 +103,7 @@ var _ = Describe("LeaseLock", func() {
104103 It ("should default the namespace to the in-cluster namespace" , func () {
105104 options .LeaseNamespace = ""
106105
107- resourceLock , err := NewResourceLock (restConfig , nil , options )
106+ resourceLock , err := NewResourceLock (restConfig , options )
108107 Expect (err ).NotTo (HaveOccurred ())
109108
110109 leaseLock := resourceLock .(* LeaseLock )
@@ -115,7 +114,7 @@ var _ = Describe("LeaseLock", func() {
115114 options .LeaseNamespace = ""
116115 fsys = fstest.MapFS {}
117116
118- Expect (NewResourceLock (restConfig , nil , options )).Error ().To (MatchError (And (
117+ Expect (NewResourceLock (restConfig , options )).Error ().To (MatchError (And (
119118 ContainSubstring ("not running in cluster" ),
120119 ContainSubstring ("please specify LeaseNamespace" ),
121120 )))
@@ -132,7 +131,7 @@ var _ = Describe("LeaseLock", func() {
132131
133132 BeforeEach (func () {
134133 var err error
135- lock , err = NewResourceLock (& rest.Config {}, nil , Options {
134+ lock , err = NewResourceLock (& rest.Config {}, Options {
136135 ControllerRingName : controllerRingName ,
137136 LeaseNamespace : namespace ,
138137 ShardName : shardName ,
@@ -235,29 +234,8 @@ var _ = Describe("LeaseLock", func() {
235234 })
236235
237236 Describe ("#RecordEvent" , func () {
238- Context ("no EventRecorder configured" , func () {
239- It ("should do nothing" , func () {
240- lock .RecordEvent ("foo" )
241- })
242- })
243-
244- Context ("EventRecorder configured" , func () {
245- var recorder * record.FakeRecorder
246-
247- BeforeEach (func () {
248- recorder = record .NewFakeRecorder (1 )
249- lock .(* LeaseLock ).LockConfig .EventRecorder = recorder
250- })
251-
252- It ("should send the event" , func () {
253- Expect (lock .Get (ctx )).Error ().To (Succeed ())
254-
255- lock .RecordEvent ("foo" )
256-
257- Eventually (recorder .Events ).Should (Receive (
258- Equal ("Normal LeaderElection " + shardName + " foo" ),
259- ))
260- })
237+ It ("should do nothing" , func () {
238+ lock .RecordEvent ("foo" )
261239 })
262240 })
263241
0 commit comments