(ctx context.Context,
file types.ConfigFile,
opts *Options,
workingDir string,
environment types.Mapping,
ct *cycleTracker,
dict map[string]interface{},
included []string,
)
| 439 | } |
| 440 | |
| 441 | func loadYamlFile(ctx context.Context, |
| 442 | file types.ConfigFile, |
| 443 | opts *Options, |
| 444 | workingDir string, |
| 445 | environment types.Mapping, |
| 446 | ct *cycleTracker, |
| 447 | dict map[string]interface{}, |
| 448 | included []string, |
| 449 | ) (map[string]interface{}, PostProcessor, error) { |
| 450 | ctx = context.WithValue(ctx, consts.ComposeFileKey{}, file.Filename) |
| 451 | if file.Content == nil && file.Config == nil { |
| 452 | content, err := os.ReadFile(file.Filename) |
| 453 | if err != nil { |
| 454 | return nil, nil, err |
| 455 | } |
| 456 | file.Content = content |
| 457 | } |
| 458 | |
| 459 | processRawYaml := func(raw interface{}, processor PostProcessor) error { |
| 460 | converted, err := convertToStringKeysRecursive(raw, "") |
| 461 | if err != nil { |
| 462 | return err |
| 463 | } |
| 464 | cfg, ok := converted.(map[string]interface{}) |
| 465 | if !ok { |
| 466 | return errors.New("top-level object must be a mapping") |
| 467 | } |
| 468 | |
| 469 | if opts.Interpolate != nil && !opts.SkipInterpolation { |
| 470 | cfg, err = interp.Interpolate(cfg, *opts.Interpolate) |
| 471 | if err != nil { |
| 472 | return err |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | fixEmptyNotNull(cfg) |
| 477 | |
| 478 | // Process includes first so that extended services have all merged attributes |
| 479 | if !opts.SkipInclude { |
| 480 | included = append(included, file.Filename) |
| 481 | err = ApplyInclude(ctx, workingDir, environment, cfg, opts, included, processor) |
| 482 | if err != nil { |
| 483 | return err |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | if err := processor.Apply(dict); err != nil { |
| 488 | return err |
| 489 | } |
| 490 | |
| 491 | // Process extends after includes so base services are fully merged |
| 492 | if !opts.SkipExtends { |
| 493 | err = ApplyExtends(ctx, cfg, opts, ct, processor) |
| 494 | if err != nil { |
| 495 | return err |
| 496 | } |
| 497 | |
| 498 | } |
no test coverage detected
searching dependent graphs…