@@ -53,15 +53,11 @@ func DontReplicateForValue(replicateValue, controller string) (result string, ch
53
53
// ReplicateFor ensures the controller string is part of the separated list of controller names
54
54
// in the internal.kcp.io/replicate label. This function changes the annotations in-place.
55
55
func 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 != "" {
61
57
existing := sets .New [string ](strings .Split (v , "," )... )
62
58
if ! existing .Has (controller ) {
63
59
existing .Insert (controller )
64
- annotations [k ] = strings .Join (sets.List [string ](existing ), "," )
60
+ annotations [core . ReplicateAnnotationKey ] = strings .Join (sets.List [string ](existing ), "," )
65
61
return annotations , true
66
62
}
67
63
return annotations , false
@@ -77,19 +73,15 @@ func ReplicateFor(annotations map[string]string, controller string) (result map[
77
73
// DontReplicateFor ensures the controller string is not part of the separated list of controller names
78
74
// in the internal.kcp.io/replicate label. This function changes the annotations in-place.
79
75
func 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 != "" {
85
77
if v == controller {
86
- delete (annotations , k )
78
+ delete (annotations , core . ReplicateAnnotationKey )
87
79
return annotations , true
88
80
}
89
81
existing := sets .New [string ](strings .Split (v , "," )... )
90
82
if existing .Has (controller ) {
91
83
existing .Delete (controller )
92
- annotations [k ] = strings .Join (sets.List [string ](existing ), "," )
84
+ annotations [core . ReplicateAnnotationKey ] = strings .Join (sets.List [string ](existing ), "," )
93
85
return annotations , true
94
86
}
95
87
return annotations , false
0 commit comments