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