@@ -589,16 +589,17 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
589589 }
590590
591591 if serviceConfig .Extends != nil && ! opts .SkipExtends {
592- baseServiceName := * serviceConfig .Extends [ "service" ]
592+ baseServiceName := serviceConfig .Extends . Service
593593 var baseService * types.ServiceConfig
594- if file := serviceConfig .Extends ["file" ]; file == nil {
594+ file := serviceConfig .Extends .File
595+ if file == "" {
595596 baseService , err = loadServiceWithExtends (filename , baseServiceName , servicesDict , workingDir , lookupEnv , opts , ct )
596597 if err != nil {
597598 return nil , err
598599 }
599600 } else {
600601 // Resolve the path to the imported file, and load it.
601- baseFilePath := absPath (workingDir , * file )
602+ baseFilePath := absPath (workingDir , file )
602603
603604 b , err := os .ReadFile (baseFilePath )
604605 if err != nil {
@@ -617,10 +618,10 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
617618 }
618619
619620 // 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
622623 // absolute path.
623- baseFileParent := filepath .Dir (* file )
624+ baseFileParent := filepath .Dir (file )
624625 if baseService .Build != nil {
625626 baseService .Build .Context = resolveBuildContextPath (baseFileParent , baseService .Build .Context )
626627 }
@@ -641,6 +642,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
641642 if err != nil {
642643 return nil , err
643644 }
645+ serviceConfig .Extends = nil
644646 }
645647
646648 return serviceConfig , nil
@@ -1048,14 +1050,15 @@ var transformDependsOnConfig TransformerFunc = func(data interface{}) (interface
10481050 }
10491051}
10501052
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 ) {
10531055 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 )
10571061 }
1058- return transformMappingOrListFunc ("=" , true )(data )
10591062}
10601063
10611064var transformServiceVolumeConfig TransformerFunc = func (data interface {}) (interface {}, error ) {
0 commit comments