Skip to content

Commit 583d2e1

Browse files
apollo13ndeloof
authored andcommitted
Merge compose extensions.
Fixes docker/compose#12724. Signed-off-by: Florian Apolloner <[email protected]>
1 parent 7058bce commit 583d2e1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

loader/loader_yaml_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func TestParseYAMLFiles(t *testing.T) {
3030
{
3131
Filename: "test.yaml",
3232
Content: []byte(`
33+
x-extension:
34+
test1: first
35+
3336
services:
3437
test:
3538
image: foo
@@ -40,6 +43,9 @@ services:
4043
{
4144
Filename: "override.yaml",
4245
Content: []byte(`
46+
x-extension:
47+
test2: second
48+
4349
services:
4450
test:
4551
image: bar
@@ -58,6 +64,10 @@ services:
5864
"init": false,
5965
},
6066
},
67+
"x-extension": map[string]interface{}{
68+
"test1": "first",
69+
"test2": "second",
70+
},
6171
})
6272
}
6373

override/merge.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"cmp"
2121
"fmt"
2222
"slices"
23-
"strings"
2423

2524
"github.com/compose-spec/compose-go/v2/tree"
2625
)
@@ -104,7 +103,7 @@ func mergeYaml(e any, o any, p tree.Path) (any, error) {
104103
func mergeMappings(mapping map[string]any, other map[string]any, p tree.Path) (map[string]any, error) {
105104
for k, v := range other {
106105
e, ok := mapping[k]
107-
if !ok || strings.HasPrefix(k, "x-") {
106+
if !ok {
108107
mapping[k] = v
109108
continue
110109
}

0 commit comments

Comments
 (0)