()
| 436 | } |
| 437 | |
| 438 | func (api *API) discoverDevcontainerProjects() error { |
| 439 | isGitProject, err := afero.DirExists(api.fs, filepath.Join(api.agentDirectory, ".git")) |
| 440 | if err != nil { |
| 441 | return xerrors.Errorf(".git dir exists: %w", err) |
| 442 | } |
| 443 | |
| 444 | // If the agent directory is a git project, we'll search |
| 445 | // the project for any `.devcontainer/devcontainer.json` |
| 446 | // files. |
| 447 | if isGitProject { |
| 448 | return api.discoverDevcontainersInProject(api.agentDirectory) |
| 449 | } |
| 450 | |
| 451 | // The agent directory is _not_ a git project, so we'll |
| 452 | // search the top level of the agent directory for any |
| 453 | // git projects, and search those. |
| 454 | entries, err := afero.ReadDir(api.fs, api.agentDirectory) |
| 455 | if err != nil { |
| 456 | return xerrors.Errorf("read agent directory: %w", err) |
| 457 | } |
| 458 | |
| 459 | for _, entry := range entries { |
| 460 | if !entry.IsDir() { |
| 461 | continue |
| 462 | } |
| 463 | |
| 464 | isGitProject, err = afero.DirExists(api.fs, filepath.Join(api.agentDirectory, entry.Name(), ".git")) |
| 465 | if err != nil { |
| 466 | return xerrors.Errorf(".git dir exists: %w", err) |
| 467 | } |
| 468 | |
| 469 | // If this directory is a git project, we'll search |
| 470 | // it for any `.devcontainer/devcontainer.json` files. |
| 471 | if isGitProject { |
| 472 | if err := api.discoverDevcontainersInProject(filepath.Join(api.agentDirectory, entry.Name())); err != nil { |
| 473 | return err |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | return nil |
| 479 | } |
| 480 | |
| 481 | func (api *API) discoverDevcontainersInProject(projectPath string) error { |
| 482 | logger := api.logger. |
no test coverage detected