Skip to content

Commit 4fbee57

Browse files
committed
fix support for nested extends in include
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 20c0997 commit 4fbee57

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

loader/extends_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,31 @@ services:
173173
assert.NilError(t, err)
174174
}
175175

176+
func TestIncludeWithExtends(t *testing.T) {
177+
yaml := `
178+
name: test-include-with-extends
179+
include:
180+
- testdata/extends/nested.yaml
181+
`
182+
abs, err := filepath.Abs(".")
183+
assert.NilError(t, err)
184+
185+
p, err := LoadWithContext(context.Background(), types.ConfigDetails{
186+
ConfigFiles: []types.ConfigFile{
187+
{
188+
Content: []byte(yaml),
189+
Filename: "(inline)",
190+
},
191+
},
192+
WorkingDir: abs,
193+
}, func(options *Options) {
194+
options.ResolvePaths = false
195+
options.SkipValidation = true
196+
})
197+
assert.NilError(t, err)
198+
assert.Check(t, p.Services["with-build"].Build != nil)
199+
}
200+
176201
func TestExtendsPortOverride(t *testing.T) {
177202
yaml := `
178203
name: test-extends-port

loader/include.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ func ApplyInclude(ctx context.Context, configDetails types.ConfigDetails, model
8383
loadOptions.ResolvePaths = true
8484
loadOptions.SkipNormalization = true
8585
loadOptions.SkipConsistencyCheck = true
86+
loadOptions.ResourceLoaders = append(loadOptions.RemoteResourceLoaders(), localResourceLoader{
87+
WorkingDir: r.ProjectDirectory,
88+
})
8689

8790
if len(r.EnvFile) == 0 {
8891
f := filepath.Join(r.ProjectDirectory, ".env")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
with-build:
3+
extends:
4+
file: sibling.yaml
5+
service: test

0 commit comments

Comments
 (0)