bumpo compose-go to v2.1.0

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours
2024-04-23 10:28:28 +02:00
parent 699fa43f7f
commit e3e16ad088
29 changed files with 146 additions and 66 deletions

View File

@ -29,12 +29,15 @@ import (
"github.com/compose-spec/compose-go/v2/types"
)
// loadIncludeConfig parse the require config from raw yaml
// loadIncludeConfig parse the required config from raw yaml
func loadIncludeConfig(source any) ([]types.IncludeConfig, error) {
if source == nil {
return nil, nil
}
configs := source.([]any)
configs, ok := source.([]any)
if !ok {
return nil, fmt.Errorf("`include` must be a list, got %s", source)
}
for i, config := range configs {
if v, ok := config.(string); ok {
configs[i] = map[string]any{
@ -73,11 +76,19 @@ func ApplyInclude(ctx context.Context, configDetails types.ConfigDetails, model
p = path
if i == 0 { // This is the "main" file, used to define project-directory. Others are overrides
relworkingdir = loader.Dir(path)
if r.ProjectDirectory == "" {
r.ProjectDirectory = filepath.Dir(path)
}
switch {
case r.ProjectDirectory == "":
relworkingdir = loader.Dir(path)
r.ProjectDirectory = filepath.Dir(path)
case !filepath.IsAbs(r.ProjectDirectory):
relworkingdir = loader.Dir(r.ProjectDirectory)
r.ProjectDirectory = filepath.Join(configDetails.WorkingDir, r.ProjectDirectory)
default:
relworkingdir = r.ProjectDirectory
}
for _, f := range included {
if f == path {
included = append(included, path)