LoadProject loads compose file according to options and bind to types.Project go structs
(ctx context.Context)
| 465 | |
| 466 | // LoadProject loads compose file according to options and bind to types.Project go structs |
| 467 | func (o *ProjectOptions) LoadProject(ctx context.Context) (*types.Project, error) { |
| 468 | config, err := o.prepare(ctx) |
| 469 | if err != nil { |
| 470 | return nil, err |
| 471 | } |
| 472 | |
| 473 | project, err := loader.LoadWithContext(ctx, types.ConfigDetails{ |
| 474 | ConfigFiles: config.ConfigFiles, |
| 475 | WorkingDir: config.WorkingDir, |
| 476 | Environment: o.Environment, |
| 477 | }, o.loadOptions...) |
| 478 | if err != nil { |
| 479 | return nil, err |
| 480 | } |
| 481 | |
| 482 | for _, config := range config.ConfigFiles { |
| 483 | project.ComposeFiles = append(project.ComposeFiles, config.Filename) |
| 484 | } |
| 485 | |
| 486 | return project, nil |
| 487 | } |
| 488 | |
| 489 | // LoadModel loads compose file according to options and returns a raw (yaml tree) model |
| 490 | func (o *ProjectOptions) LoadModel(ctx context.Context) (map[string]any, error) { |