prepare converts ProjectOptions into loader's types.ConfigDetails and configures default load options
(ctx context.Context)
| 498 | |
| 499 | // prepare converts ProjectOptions into loader's types.ConfigDetails and configures default load options |
| 500 | func (o *ProjectOptions) prepare(ctx context.Context) (*types.ConfigDetails, error) { |
| 501 | defaultDir, err := o.GetWorkingDir() |
| 502 | if err != nil { |
| 503 | return &types.ConfigDetails{}, err |
| 504 | } |
| 505 | |
| 506 | configDetails, err := o.ReadConfigFiles(ctx, defaultDir, o) |
| 507 | if err != nil { |
| 508 | return configDetails, err |
| 509 | } |
| 510 | |
| 511 | isNamed := false |
| 512 | if o.Name == "" { |
| 513 | type named struct { |
| 514 | Name string `yaml:"name,omitempty"` |
| 515 | } |
| 516 | // if any of the compose file is named, this is equivalent to user passing --project-name |
| 517 | for _, cfg := range configDetails.ConfigFiles { |
| 518 | var n named |
| 519 | err = yaml.Unmarshal(cfg.Content, &n) |
| 520 | if err != nil { |
| 521 | return nil, err |
| 522 | } |
| 523 | if n.Name != "" { |
| 524 | isNamed = true |
| 525 | break |
| 526 | } |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | o.loadOptions = append(o.loadOptions, |
| 531 | withNamePrecedenceLoad(defaultDir, isNamed, o), |
| 532 | withConvertWindowsPaths(o), |
| 533 | withListeners(o)) |
| 534 | |
| 535 | return configDetails, nil |
| 536 | } |
| 537 | |
| 538 | // ProjectFromOptions load a compose project based on command line options |
| 539 | // Deprecated: use ProjectOptions.LoadProject or ProjectOptions.LoadModel |
no test coverage detected