@@ -82,16 +82,17 @@ func applyServiceExtends(ctx context.Context, name string, services map[string]a
82
82
)
83
83
84
84
if file != nil {
85
- filename = file .(string )
86
- services , processor , err = getExtendsBaseFromFile (ctx , ref , filename , opts , tracker )
85
+ refFilename : = file .(string )
86
+ services , processor , err = getExtendsBaseFromFile (ctx , name , ref , filename , refFilename , opts , tracker )
87
87
post = append (post , processor )
88
88
if err != nil {
89
89
return nil , err
90
90
}
91
+ filename = refFilename
91
92
} else {
92
93
_ , ok := services [ref ]
93
94
if ! ok {
94
- return nil , fmt .Errorf ("cannot extend service %q in %s: service not found" , name , filename )
95
+ return nil , fmt .Errorf ("cannot extend service %q in %s: service %q not found" , name , filename , ref )
95
96
}
96
97
}
97
98
@@ -127,17 +128,17 @@ func applyServiceExtends(ctx context.Context, name string, services map[string]a
127
128
return merged , nil
128
129
}
129
130
130
- func getExtendsBaseFromFile (ctx context.Context , name string , path string , opts * Options , ct * cycleTracker ) (map [string ]any , PostProcessor , error ) {
131
+ func getExtendsBaseFromFile (ctx context.Context , name , ref string , path , refPath string , opts * Options , ct * cycleTracker ) (map [string ]any , PostProcessor , error ) {
131
132
for _ , loader := range opts .ResourceLoaders {
132
- if ! loader .Accept (path ) {
133
+ if ! loader .Accept (refPath ) {
133
134
continue
134
135
}
135
- local , err := loader .Load (ctx , path )
136
+ local , err := loader .Load (ctx , refPath )
136
137
if err != nil {
137
138
return nil , nil , err
138
139
}
139
140
localdir := filepath .Dir (local )
140
- relworkingdir := loader .Dir (path )
141
+ relworkingdir := loader .Dir (refPath )
141
142
142
143
extendsOpts := opts .clone ()
143
144
// replace localResourceLoader with a new flavour, using extended file base path
@@ -157,9 +158,15 @@ func getExtendsBaseFromFile(ctx context.Context, name string, path string, opts
157
158
return nil , nil , err
158
159
}
159
160
services := source ["services" ].(map [string ]any )
160
- _ , ok := services [name ]
161
+ _ , ok := services [ref ]
161
162
if ! ok {
162
- return nil , nil , fmt .Errorf ("cannot extend service %q in %s: service not found" , name , path )
163
+ return nil , nil , fmt .Errorf (
164
+ "cannot extend service %q in %s: service %q not found in %s" ,
165
+ name ,
166
+ path ,
167
+ ref ,
168
+ refPath ,
169
+ )
163
170
}
164
171
165
172
var remotes []paths.RemoteResource
@@ -173,7 +180,7 @@ func getExtendsBaseFromFile(ctx context.Context, name string, path string, opts
173
180
174
181
return services , processor , nil
175
182
}
176
- return nil , nil , fmt .Errorf ("cannot read %s" , path )
183
+ return nil , nil , fmt .Errorf ("cannot read %s" , refPath )
177
184
}
178
185
179
186
func deepClone (value any ) any {
0 commit comments