@@ -589,16 +589,17 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
589
589
}
590
590
591
591
if serviceConfig .Extends != nil && ! opts .SkipExtends {
592
- baseServiceName := * serviceConfig .Extends [ "service" ]
592
+ baseServiceName := serviceConfig .Extends . Service
593
593
var baseService * types.ServiceConfig
594
- if file := serviceConfig .Extends ["file" ]; file == nil {
594
+ file := serviceConfig .Extends .File
595
+ if file == "" {
595
596
baseService , err = loadServiceWithExtends (filename , baseServiceName , servicesDict , workingDir , lookupEnv , opts , ct )
596
597
if err != nil {
597
598
return nil , err
598
599
}
599
600
} else {
600
601
// Resolve the path to the imported file, and load it.
601
- baseFilePath := absPath (workingDir , * file )
602
+ baseFilePath := absPath (workingDir , file )
602
603
603
604
b , err := os .ReadFile (baseFilePath )
604
605
if err != nil {
@@ -617,10 +618,10 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
617
618
}
618
619
619
620
// Make paths relative to the importing Compose file. Note that we
620
- // make the paths relative to `* file` rather than `baseFilePath` so
621
- // that the resulting paths won't be absolute if `* file` isn't an
621
+ // make the paths relative to `file` rather than `baseFilePath` so
622
+ // that the resulting paths won't be absolute if `file` isn't an
622
623
// absolute path.
623
- baseFileParent := filepath .Dir (* file )
624
+ baseFileParent := filepath .Dir (file )
624
625
if baseService .Build != nil {
625
626
baseService .Build .Context = resolveBuildContextPath (baseFileParent , baseService .Build .Context )
626
627
}
@@ -641,6 +642,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
641
642
if err != nil {
642
643
return nil , err
643
644
}
645
+ serviceConfig .Extends = nil
644
646
}
645
647
646
648
return serviceConfig , nil
@@ -1048,14 +1050,15 @@ var transformDependsOnConfig TransformerFunc = func(data interface{}) (interface
1048
1050
}
1049
1051
}
1050
1052
1051
- var transformExtendsConfig TransformerFunc = func (data interface {}) (interface {}, error ) {
1052
- switch data .(type ) {
1053
+ var transformExtendsConfig TransformerFunc = func (value interface {}) (interface {}, error ) {
1054
+ switch value .(type ) {
1053
1055
case string :
1054
- data = map [string ]interface {}{
1055
- "service" : data ,
1056
- }
1056
+ return map [string ]interface {}{"service" : value }, nil
1057
+ case map [string ]interface {}:
1058
+ return value , nil
1059
+ default :
1060
+ return value , errors .Errorf ("invalid type %T for extends" , value )
1057
1061
}
1058
- return transformMappingOrListFunc ("=" , true )(data )
1059
1062
}
1060
1063
1061
1064
var transformServiceVolumeConfig TransformerFunc = func (data interface {}) (interface {}, error ) {
0 commit comments