Skip to content

Commit af99b4f

Browse files
author
guozhi.li
committed
add MergeAnnotations func
1 parent db420c7 commit af99b4f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

operator/redisfailover/util/label.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ func MergeLabels(allLabels ...map[string]string) map[string]string {
1111
}
1212
return res
1313
}
14+
15+
// MergeAnnotations merges all the annotations maps received as argument into a single new label map.
16+
func MergeAnnotations(allMergeAnnotations ...map[string]string) map[string]string {
17+
res := map[string]string{}
18+
19+
for _, labels := range allMergeAnnotations {
20+
for k, v := range labels {
21+
res[k] = v
22+
}
23+
}
24+
return res
25+
}

service/k8s/statefulset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (s *StatefulSetService) CreateOrUpdateStatefulSet(namespace string, statefu
101101
// namespace is our spec(https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#concurrency-control-and-consistency),
102102
// we will replace the current namespace state.
103103
statefulSet.ResourceVersion = storedStatefulSet.ResourceVersion
104-
statefulSet.Annotations = util.MergeLabels(statefulSet.Annotations, storedStatefulSet.Annotations)
104+
statefulSet.Annotations = util.MergeAnnotations(statefulSet.Annotations, storedStatefulSet.Annotations)
105105
return s.UpdateStatefulSet(namespace, statefulSet)
106106
}
107107

0 commit comments

Comments
 (0)