@@ -307,7 +307,7 @@ var _ = Describe("application", func() {
307307
308308ctx , cancel := context .WithCancel (context .Background ())
309309defer cancel ()
310- doReconcileTest (ctx , "3" , bldr , m , false )
310+ doReconcileTest (ctx , "3" , m , false , bldr )
311311}, 10 )
312312
313313It ("should Reconcile Watches objects" , func () {
@@ -322,7 +322,7 @@ var _ = Describe("application", func() {
322322
323323ctx , cancel := context .WithCancel (context .Background ())
324324defer cancel ()
325- doReconcileTest (ctx , "4" , bldr , m , true )
325+ doReconcileTest (ctx , "4" , m , true , bldr )
326326}, 10 )
327327})
328328
@@ -378,7 +378,7 @@ var _ = Describe("application", func() {
378378
379379ctx , cancel := context .WithCancel (context .Background ())
380380defer cancel ()
381- doReconcileTest (ctx , "5" , bldr , m , true )
381+ doReconcileTest (ctx , "5" , m , true , bldr )
382382
383383Expect (deployPrctExecuted ).To (BeTrue (), "Deploy predicated should be called at least once" )
384384Expect (replicaSetPrctExecuted ).To (BeTrue (), "ReplicaSet predicated should be called at least once" )
@@ -396,6 +396,16 @@ var _ = Describe("application", func() {
396396Expect (err ).NotTo (HaveOccurred ())
397397})
398398
399+ It ("should support multiple controllers watching the same metadata kind" , func () {
400+ bldr1 := ControllerManagedBy (mgr ).For (& appsv1.Deployment {}, OnlyMetadata )
401+ bldr2 := ControllerManagedBy (mgr ).For (& appsv1.Deployment {}, OnlyMetadata )
402+
403+ ctx , cancel := context .WithCancel (context .Background ())
404+ defer cancel ()
405+
406+ doReconcileTest (ctx , "6" , mgr , true , bldr1 , bldr2 )
407+ })
408+
399409It ("should support watching For, Owns, and Watch as metadata" , func () {
400410statefulSetMaps := make (chan * metav1.PartialObjectMetadata )
401411
@@ -421,7 +431,7 @@ var _ = Describe("application", func() {
421431
422432ctx , cancel := context .WithCancel (context .Background ())
423433defer cancel ()
424- doReconcileTest (ctx , "8" , bldr , mgr , true )
434+ doReconcileTest (ctx , "8" , mgr , true , bldr )
425435
426436By ("Creating a new stateful set" )
427437set := & appsv1.StatefulSet {
@@ -496,7 +506,7 @@ func (c *nonTypedOnlyCache) GetInformerForKind(ctx context.Context, gvk schema.G
496506
497507// TODO(directxman12): this function has too many arguments, and the whole
498508// "nameSuffix" think is a bit of a hack It should be cleaned up significantly by someone with a bit of time.
499- func doReconcileTest (ctx context.Context , nameSuffix string , blder * Builder , mgr manager.Manager , complete bool ) {
509+ func doReconcileTest (ctx context.Context , nameSuffix string , mgr manager.Manager , complete bool , blders ... * Builder ) {
500510deployName := "deploy-name-" + nameSuffix
501511rsName := "rs-name-" + nameSuffix
502512
@@ -512,15 +522,17 @@ func doReconcileTest(ctx context.Context, nameSuffix string, blder *Builder, mgr
512522return reconcile.Result {}, nil
513523})
514524
515- if complete {
516- err := blder .Complete (fn )
517- Expect (err ).NotTo (HaveOccurred ())
518- } else {
519- var err error
520- var c controller.Controller
521- c , err = blder .Build (fn )
522- Expect (err ).NotTo (HaveOccurred ())
523- Expect (c ).NotTo (BeNil ())
525+ for _ , blder := range blders {
526+ if complete {
527+ err := blder .Complete (fn )
528+ Expect (err ).NotTo (HaveOccurred ())
529+ } else {
530+ var err error
531+ var c controller.Controller
532+ c , err = blder .Build (fn )
533+ Expect (err ).NotTo (HaveOccurred ())
534+ Expect (c ).NotTo (BeNil ())
535+ }
524536}
525537
526538By ("Starting the application" )
0 commit comments