ReadConfigFiles reads ConfigFiles and populates the content field
(ctx context.Context, workingDir string, options *ProjectOptions)
| 431 | |
| 432 | // ReadConfigFiles reads ConfigFiles and populates the content field |
| 433 | func (o *ProjectOptions) ReadConfigFiles(ctx context.Context, workingDir string, options *ProjectOptions) (*types.ConfigDetails, error) { |
| 434 | config, err := loader.LoadConfigFiles(ctx, options.ConfigPaths, workingDir, options.loadOptions...) |
| 435 | if err != nil { |
| 436 | return nil, err |
| 437 | } |
| 438 | configs := make([][]byte, len(config.ConfigFiles)) |
| 439 | |
| 440 | for i, c := range config.ConfigFiles { |
| 441 | var err error |
| 442 | var b []byte |
| 443 | if c.IsStdin() { |
| 444 | b, err = io.ReadAll(os.Stdin) |
| 445 | if err != nil { |
| 446 | return nil, err |
| 447 | } |
| 448 | } else { |
| 449 | f, err := filepath.Abs(c.Filename) |
| 450 | if err != nil { |
| 451 | return nil, err |
| 452 | } |
| 453 | b, err = os.ReadFile(f) |
| 454 | if err != nil { |
| 455 | return nil, err |
| 456 | } |
| 457 | } |
| 458 | configs[i] = b |
| 459 | } |
| 460 | for i, c := range configs { |
| 461 | config.ConfigFiles[i].Content = c |
| 462 | } |
| 463 | return config, nil |
| 464 | } |
| 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) { |
no test coverage detected