@@ -11,6 +11,11 @@ import (
11
11
)
12
12
13
13
func mergeAppend (src , dest map [string ]any ) error {
14
+ // mergeAppend recursively merges the src map into the dest map (left to right),
15
+ // modifying and expanding the dest map in the process.
16
+ // This function does not overwrite component lists, and ensures that the
17
+ // final value is a name-aware copy of lists from src and dest.
18
+
14
19
// Compile the globs once
15
20
patterns := []string {
16
21
"service::extensions" ,
@@ -28,13 +33,13 @@ func mergeAppend(src, dest map[string]any) error {
28
33
srcFlat , _ := maps .Flatten (src , []string {}, KeyDelimiter )
29
34
destFlat , _ := maps .Flatten (dest , []string {}, KeyDelimiter )
30
35
31
- for key , sVal := range srcFlat {
32
- if ! isMatch (key , globs ) {
36
+ for sKey , sVal := range srcFlat {
37
+ if ! isMatch (sKey , globs ) {
33
38
continue
34
39
}
35
40
36
- dVal , exists := destFlat [key ]
37
- if ! exists {
41
+ dVal , dOk := destFlat [sKey ]
42
+ if ! dOk {
38
43
continue // Let maps.Merge handle missing keys
39
44
}
40
45
@@ -43,7 +48,7 @@ func mergeAppend(src, dest map[string]any) error {
43
48
44
49
// Only merge if the value is a slice or array; let maps.Merge handle other types
45
50
if srcVal .Kind () == reflect .Slice || srcVal .Kind () == reflect .Array {
46
- srcFlat [key ] = mergeSlice (srcVal , destVal )
51
+ srcFlat [sKey ] = mergeSlice (srcVal , destVal )
47
52
}
48
53
}
49
54
0 commit comments