Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 748d6a3

Browse files
committed
Added extends support when given as string
Fixes #428 Now if extends is given as string as in below docker-compose file, ``` version: '2' services: foo: image: foo bar: extends: foo ``` libcompose will support it. Signed-off-by: Suraj Narwade <[email protected]>
1 parent 8e4221d commit 748d6a3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

config/merge.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/docker/libcompose/utils"
1111
composeYaml "github.com/docker/libcompose/yaml"
1212
"gopkg.in/yaml.v2"
13+
"reflect"
1314
)
1415

1516
var (
@@ -60,6 +61,18 @@ func Merge(existingServices *ServiceConfigs, environmentLookup EnvironmentLookup
6061
}
6162
baseRawServices := config.Services
6263

64+
for service, data := range baseRawServices {
65+
for key, value := range data {
66+
//check for "extends" key and check whether it is string or not
67+
if key == "extends" && reflect.TypeOf(value).Kind() == reflect.String {
68+
//converting string to map
69+
extendMap := make(map[interface{}]interface{})
70+
extendMap["service"] = value
71+
baseRawServices[service][key] = extendMap
72+
}
73+
}
74+
}
75+
6376
if options.Interpolate {
6477
if err := InterpolateRawServiceMap(&baseRawServices, environmentLookup); err != nil {
6578
return "", nil, nil, nil, err

0 commit comments

Comments
 (0)