@@ -53,15 +53,11 @@ func DontReplicateForValue(replicateValue, controller string) (result string, ch
5353// ReplicateFor ensures the controller string is part of the separated list of controller names
5454// in the internal.kcp.io/replicate label. This function changes the annotations in-place.
5555func ReplicateFor (annotations map [string ]string , controller string ) (result map [string ]string , changed bool ) {
56- for k , v := range annotations {
57- if k != core .ReplicateAnnotationKey {
58- continue
59- }
60-
56+ if v := annotations [core .ReplicateAnnotationKey ]; v != "" {
6157 existing := sets .New [string ](strings .Split (v , "," )... )
6258 if ! existing .Has (controller ) {
6359 existing .Insert (controller )
64- annotations [k ] = strings .Join (sets.List [string ](existing ), "," )
60+ annotations [core . ReplicateAnnotationKey ] = strings .Join (sets.List [string ](existing ), "," )
6561 return annotations , true
6662 }
6763 return annotations , false
@@ -77,19 +73,15 @@ func ReplicateFor(annotations map[string]string, controller string) (result map[
7773// DontReplicateFor ensures the controller string is not part of the separated list of controller names
7874// in the internal.kcp.io/replicate label. This function changes the annotations in-place.
7975func DontReplicateFor (annotations map [string ]string , controller string ) (result map [string ]string , changed bool ) {
80- for k , v := range annotations {
81- if k != core .ReplicateAnnotationKey {
82- continue
83- }
84-
76+ if v := annotations [core .ReplicateAnnotationKey ]; v != "" {
8577 if v == controller {
86- delete (annotations , k )
78+ delete (annotations , core . ReplicateAnnotationKey )
8779 return annotations , true
8880 }
8981 existing := sets .New [string ](strings .Split (v , "," )... )
9082 if existing .Has (controller ) {
9183 existing .Delete (controller )
92- annotations [k ] = strings .Join (sets.List [string ](existing ), "," )
84+ annotations [core . ReplicateAnnotationKey ] = strings .Join (sets.List [string ](existing ), "," )
9385 return annotations , true
9486 }
9587 return annotations , false
0 commit comments