@@ -142,7 +142,7 @@ var _ = Describe("Exceptions", func() {
142
142
tc .treeSelector = ReplaceStrings (tc .treeSelector , names )
143
143
144
144
// Create a Role with the selector and treeSelector annotation
145
- MakeObjectWithAnnotation (ctx , api .RoleResource , names [p ], "testrole" , map [string ]string {
145
+ MakeObjectWithAnnotations (ctx , api .RoleResource , names [p ], "testrole" , map [string ]string {
146
146
api .AnnotationSelector : tc .selector ,
147
147
api .AnnotationTreeSelector : tc .treeSelector ,
148
148
api .AnnotationNoneSelector : tc .noneSelector ,
@@ -215,7 +215,7 @@ var _ = Describe("Exceptions", func() {
215
215
}
216
216
217
217
// update the role with the selector and treeSelector annotation
218
- UpdateObjectWithAnnotation (ctx , api .RoleResource , names [p ], "testrole" , map [string ]string {
218
+ UpdateObjectWithAnnotations (ctx , api .RoleResource , names [p ], "testrole" , map [string ]string {
219
219
api .AnnotationSelector : tc .selector ,
220
220
api .AnnotationTreeSelector : tc .treeSelector ,
221
221
api .AnnotationNoneSelector : tc .noneSelector ,
@@ -232,7 +232,7 @@ var _ = Describe("Exceptions", func() {
232
232
}
233
233
234
234
// remove the annotation and verify that the object is back for every namespace
235
- UpdateObjectWithAnnotation (ctx , api .RoleResource , names [p ], "testrole" , map [string ]string {})
235
+ UpdateObjectWithAnnotations (ctx , api .RoleResource , names [p ], "testrole" , map [string ]string {})
236
236
for _ , ns := range names {
237
237
Eventually (HasObject (ctx , api .RoleResource , ns , "testrole" )).Should (BeTrue (), "When propagating testrole to %s" , ns )
238
238
}
@@ -304,7 +304,7 @@ var _ = Describe("Exceptions", func() {
304
304
Eventually (HasObject (ctx , api .RoleResource , names [nolabelchild ], "testrole" )).Should (BeTrue (), "When propagating testrole to %s" , names [nolabelchild ])
305
305
// Add `select` exception annotation with propagate label and verify the
306
306
// object is only propagated to children with the label.
307
- UpdateObjectWithAnnotation (ctx , api .RoleResource , names [p ], "testrole" , map [string ]string {
307
+ UpdateObjectWithAnnotations (ctx , api .RoleResource , names [p ], "testrole" , map [string ]string {
308
308
api .AnnotationSelector : label ,
309
309
})
310
310
Eventually (HasObject (ctx , api .RoleResource , names [nolabelchild ], "testrole" )).Should (BeFalse (), "When propagating testrole to %s" , names [nolabelchild ])
@@ -398,7 +398,7 @@ var _ = Describe("Basic propagation", func() {
398
398
Expect (ObjectInheritedFrom (ctx , "configmaps" , barName , "foo-config" )).Should (Equal (fooName ))
399
399
})
400
400
401
- It ("should not propagate builtin exclusions" , func () {
401
+ It ("should not propagate builtin exclusions by name " , func () {
402
402
SetParent (ctx , barName , fooName )
403
403
MakeObject (ctx , "configmaps" , fooName , "istio-ca-root-cert" )
404
404
MakeObject (ctx , "configmaps" , fooName , "kube-root-ca.crt" )
@@ -411,6 +411,27 @@ var _ = Describe("Basic propagation", func() {
411
411
Eventually (HasObject (ctx , "configmaps" , barName , "kube-root-ca.crt" )).Should (BeFalse ())
412
412
})
413
413
414
+ It ("should not propagate builtin exclusions by labels" , func () {
415
+ SetParent (ctx , barName , fooName )
416
+ MakeObjectWithLabels (ctx , "roles" , fooName , "role-with-labels-blocked" , map [string ]string {"cattle.io/creator" : "norman" })
417
+ MakeObjectWithLabels (ctx , "roles" , fooName , "role-with-labels-wrong-value" , map [string ]string {"cattle.io/creator" : "testme" })
418
+ MakeObjectWithLabels (ctx , "roles" , fooName , "role-with-labels-something" , map [string ]string {"app" : "hello-world" })
419
+ AddToHNCConfig (ctx , api .RBACGroup , api .RoleKind , api .Propagate )
420
+
421
+ // the first one should not propagate, everything else should
422
+ Consistently (HasObject (ctx , "roles" , barName , "role-with-labels-blocked" )).Should (BeFalse ())
423
+ Eventually (HasObject (ctx , "roles" , barName , "role-with-labels-wrong-value" )).Should (BeTrue ())
424
+ Eventually (HasObject (ctx , "roles" , barName , "role-with-labels-something" )).Should (BeTrue ())
425
+
426
+ // lets try the same with config maps, they are also filtered and should not propagate
427
+ MakeObjectWithLabels (ctx , "configmaps" , fooName , "cm-with-label-1" , map [string ]string {"cattle.io/creator" : "norman" })
428
+ MakeObjectWithLabels (ctx , "configmaps" , fooName , "cm-with-label-2" , map [string ]string {"app" : "hello-world" })
429
+ AddToHNCConfig (ctx , "" , "configmaps" , api .Propagate )
430
+
431
+ Consistently (HasObject (ctx , "configmaps" , barName , "cm-with-label-1" )).Should (BeFalse ())
432
+ Eventually (HasObject (ctx , "configmaps" , barName , "cm-with-label-2" )).Should (BeTrue ())
433
+ })
434
+
414
435
It ("should be removed if the hierarchy changes" , func () {
415
436
SetParent (ctx , barName , fooName )
416
437
SetParent (ctx , bazName , barName )
@@ -658,7 +679,7 @@ var _ = Describe("Basic propagation", func() {
658
679
659
680
It ("should avoid propagating banned annotations" , func () {
660
681
SetParent (ctx , barName , fooName )
661
- MakeObjectWithAnnotation (ctx , "roles" , fooName , "foo-annot-role" , map [string ]string {
682
+ MakeObjectWithAnnotations (ctx , "roles" , fooName , "foo-annot-role" , map [string ]string {
662
683
"annot-a" : "value-a" ,
663
684
"annot-b" : "value-b" ,
664
685
})
@@ -682,7 +703,7 @@ var _ = Describe("Basic propagation", func() {
682
703
683
704
// Tell the HNC config not to propagate annot-a and verify that this time, it's not annotated
684
705
config .UnpropagatedAnnotations = []string {"annot-a" }
685
- MakeObjectWithAnnotation (ctx , "roles" , fooName , "foo-annot-role" , map [string ]string {
706
+ MakeObjectWithAnnotations (ctx , "roles" , fooName , "foo-annot-role" , map [string ]string {
686
707
"annot-a" : "value-a" ,
687
708
"annot-b" : "value-b" ,
688
709
})
0 commit comments