@@ -42,6 +42,12 @@ import (
42
42
"sigs.k8s.io/controller-runtime/pkg/source"
43
43
)
44
44
45
+ type typedNoop struct {}
46
+
47
+ func (typedNoop ) Reconcile (reconcile.Request ) (reconcile.Result , error ) {
48
+ return reconcile.Result {}, nil
49
+ }
50
+
45
51
var _ = Describe ("application" , func () {
46
52
var stop chan struct {}
47
53
@@ -152,6 +158,27 @@ var _ = Describe("application", func() {
152
158
Expect (instance ).NotTo (BeNil ())
153
159
})
154
160
161
+ It ("should prefer reconciler from options during creation of controller" , func () {
162
+ newController = func (name string , mgr manager.Manager , options controller.Options ) (controller.Controller , error ) {
163
+ if options .Reconciler != (typedNoop {}) {
164
+ return nil , fmt .Errorf ("Custom reconciler expected %T but found %T" , typedNoop {}, options .Reconciler )
165
+ }
166
+ return controller .New (name , mgr , options )
167
+ }
168
+
169
+ By ("creating a controller manager" )
170
+ m , err := manager .New (cfg , manager.Options {})
171
+ Expect (err ).NotTo (HaveOccurred ())
172
+
173
+ instance , err := ControllerManagedBy (m ).
174
+ For (& appsv1.ReplicaSet {}).
175
+ Owns (& appsv1.ReplicaSet {}).
176
+ WithOptions (controller.Options {Reconciler : typedNoop {}}).
177
+ Build (noop )
178
+ Expect (err ).NotTo (HaveOccurred ())
179
+ Expect (instance ).NotTo (BeNil ())
180
+ })
181
+
155
182
It ("should allow multiple controllers for the same kind" , func () {
156
183
By ("creating a controller manager" )
157
184
m , err := manager .New (cfg , manager.Options {})
0 commit comments