Skip to content

Commit 9ba7b1e

Browse files
ndeloofglours
authored andcommitted
use listener to collect include metadata
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 26a5dd3 commit 9ba7b1e

File tree

4 files changed

+9
-32
lines changed

4 files changed

+9
-32
lines changed

loader/include.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ func ApplyInclude(ctx context.Context, configDetails types.ConfigDetails, model
5353
return err
5454
}
5555
for _, r := range includeConfig {
56+
for _, listener := range options.Listeners {
57+
listener("include", map[string]any{
58+
"path": r.Path,
59+
"workingdir": configDetails.WorkingDir,
60+
})
61+
}
62+
5663
for i, p := range r.Path {
5764
for _, loader := range options.ResourceLoaders {
5865
if loader.Accept(p) {

loader/loader.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,6 @@ func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options,
468468
}
469469
loaded = append(loaded, mainFile)
470470

471-
includeRefs := make(map[string][]types.IncludeConfig)
472-
473471
dict, err := loadYamlModel(ctx, configDetails, opts, &cycleTracker{}, nil)
474472
if err != nil {
475473
return nil, err
@@ -496,10 +494,6 @@ func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options,
496494
return nil, err
497495
}
498496

499-
if len(includeRefs) != 0 {
500-
project.IncludeReferences = includeRefs
501-
}
502-
503497
if !opts.SkipNormalization {
504498
err := Normalize(project)
505499
if err != nil {

loader/paths.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,6 @@ func ResolveRelativePaths(project *types.Project) error {
3737
return err
3838
}
3939
project.ComposeFiles = absComposeFiles
40-
41-
// don't coerce a nil map to an empty map
42-
if project.IncludeReferences != nil {
43-
absIncludes := make(map[string][]types.IncludeConfig, len(project.IncludeReferences))
44-
for filename, config := range project.IncludeReferences {
45-
filename = absPath(project.WorkingDir, filename)
46-
absConfigs := make([]types.IncludeConfig, len(config))
47-
for i, c := range config {
48-
absConfigs[i] = types.IncludeConfig{
49-
Path: resolvePaths(project.WorkingDir, c.Path),
50-
ProjectDirectory: absPath(project.WorkingDir, c.ProjectDirectory),
51-
EnvFile: resolvePaths(project.WorkingDir, c.EnvFile),
52-
}
53-
}
54-
absIncludes[filename] = absConfigs
55-
}
56-
project.IncludeReferences = absIncludes
57-
}
58-
5940
return nil
6041
}
6142

types/project.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,8 @@ type Project struct {
4747
Configs Configs `yaml:"configs,omitempty" json:"configs,omitempty"`
4848
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"` // https://github.com/golang/go/issues/6213
4949

50-
// IncludeReferences is keyed by Compose YAML filename and contains config for
51-
// other Compose YAML files it directly triggered a load of via `include`.
52-
//
53-
// Note: this is
54-
IncludeReferences map[string][]IncludeConfig `yaml:"-" json:"-"`
55-
ComposeFiles []string `yaml:"-" json:"-"`
56-
Environment Mapping `yaml:"-" json:"-"`
50+
ComposeFiles []string `yaml:"-" json:"-"`
51+
Environment Mapping `yaml:"-" json:"-"`
5752

5853
// DisabledServices track services which have been disable as profile is not active
5954
DisabledServices Services `yaml:"-" json:"-"`

0 commit comments

Comments
 (0)