(ctx context.Context, configDetails types.ConfigDetails, opts *Options, loaded []string)
| 557 | } |
| 558 | |
| 559 | func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options, loaded []string) (map[string]interface{}, error) { |
| 560 | mainFile := configDetails.ConfigFiles[0].Filename |
| 561 | for _, f := range loaded { |
| 562 | if f == mainFile { |
| 563 | loaded = append(loaded, mainFile) |
| 564 | return nil, fmt.Errorf("include cycle detected:\n%s\n include %s", loaded[0], strings.Join(loaded[1:], "\n include ")) |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | dict, err := loadYamlModel(ctx, configDetails, opts, &cycleTracker{}, nil) |
| 569 | if err != nil { |
| 570 | return nil, err |
| 571 | } |
| 572 | |
| 573 | if len(dict) == 0 { |
| 574 | return nil, errors.New("empty compose file") |
| 575 | } |
| 576 | |
| 577 | if !opts.SkipValidation && opts.projectName == "" { |
| 578 | return nil, errors.New("project name must not be empty") |
| 579 | } |
| 580 | |
| 581 | if !opts.SkipNormalization { |
| 582 | dict["name"] = opts.projectName |
| 583 | dict, err = Normalize(dict, configDetails.Environment) |
| 584 | if err != nil { |
| 585 | return nil, err |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | return dict, nil |
| 590 | } |
| 591 | |
| 592 | // ModelToProject binds a canonical yaml dict into compose-go structs |
| 593 | func ModelToProject(dict map[string]interface{}, opts *Options, configDetails types.ConfigDetails) (*types.Project, error) { |
no test coverage detected
searching dependent graphs…