Skip to content

Commit

Permalink
fix support for nested extends in include
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Feb 6, 2024
1 parent 20c0997 commit 4fbee57
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions loader/extends_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,31 @@ services:
assert.NilError(t, err)
}

func TestIncludeWithExtends(t *testing.T) {
yaml := `
name: test-include-with-extends
include:
- testdata/extends/nested.yaml
`
abs, err := filepath.Abs(".")
assert.NilError(t, err)

p, err := LoadWithContext(context.Background(), types.ConfigDetails{
ConfigFiles: []types.ConfigFile{
{
Content: []byte(yaml),
Filename: "(inline)",
},
},
WorkingDir: abs,
}, func(options *Options) {
options.ResolvePaths = false
options.SkipValidation = true
})
assert.NilError(t, err)
assert.Check(t, p.Services["with-build"].Build != nil)
}

func TestExtendsPortOverride(t *testing.T) {
yaml := `
name: test-extends-port
Expand Down
3 changes: 3 additions & 0 deletions loader/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func ApplyInclude(ctx context.Context, configDetails types.ConfigDetails, model
loadOptions.ResolvePaths = true
loadOptions.SkipNormalization = true
loadOptions.SkipConsistencyCheck = true
loadOptions.ResourceLoaders = append(loadOptions.RemoteResourceLoaders(), localResourceLoader{
WorkingDir: r.ProjectDirectory,
})

if len(r.EnvFile) == 0 {
f := filepath.Join(r.ProjectDirectory, ".env")
Expand Down
5 changes: 5 additions & 0 deletions loader/testdata/extends/nested.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
with-build:
extends:
file: sibling.yaml
service: test

0 comments on commit 4fbee57

Please sign in to comment.