Skip to content

Commit 30de3de

Browse files
authored
Merge pull request #261 from shangchengbabaiban/main
refactor: use maps.Copy for cleaner map handling
2 parents fa8539b + 864ae4e commit 30de3de

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

internal/controller/common/kube/helpers.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"encoding/json"
1010
"fmt"
11+
"maps"
1112
"sort"
1213
"strconv"
1314

@@ -33,12 +34,10 @@ func GetCommonLabels(kind string, meta metav1.ObjectMeta, additionalLabels ...ma
3334
}
3435

3536
// CombineMaps takes an arbitrary number of maps and combines them to one map[string]string
36-
func CombineMaps(maps ...map[string]string) map[string]string {
37+
func CombineMaps(ms ...map[string]string) map[string]string {
3738
var keyvalues = make(map[string]string)
38-
for _, m := range maps {
39-
for k, v := range m {
40-
keyvalues[k] = v
41-
}
39+
for _, m := range ms {
40+
maps.Copy(keyvalues, m)
4241
}
4342

4443
return keyvalues

0 commit comments

Comments
 (0)