(f factory.Factory, composePath string)
| 548 | } |
| 549 | |
| 550 | func (cmd *InitCmd) initDockerCompose(f factory.Factory, composePath string) error { |
| 551 | project, err := compose.LoadDockerComposeProject(composePath) |
| 552 | if err != nil { |
| 553 | return err |
| 554 | } |
| 555 | |
| 556 | projectName, _, err := getProjectName() |
| 557 | if err != nil { |
| 558 | return err |
| 559 | } |
| 560 | |
| 561 | project.Name = projectName |
| 562 | |
| 563 | // Prompt user for entrypoints for each container with sync folders. |
| 564 | for idx, service := range project.Services { |
| 565 | localPaths := compose.GetServiceSyncPaths(project, service) |
| 566 | noEntryPoint := len(service.Entrypoint) == 0 |
| 567 | hasSyncEndpoints := len(localPaths) > 0 |
| 568 | |
| 569 | if noEntryPoint && hasSyncEndpoints { |
| 570 | entrypointStr, err := cmd.log.Question(&survey.QuestionOptions{ |
| 571 | Question: "How is this container started? (e.g. npm start, gradle run, go run main.go)", |
| 572 | }) |
| 573 | if err != nil { |
| 574 | return err |
| 575 | } |
| 576 | |
| 577 | entrypoint := strings.Split(entrypointStr, " ") |
| 578 | project.Services[idx].Entrypoint = entrypoint |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | // Generate DevSpace configuration |
| 583 | composeManager := compose.NewComposeManager(project) |
| 584 | err = composeManager.Load(cmd.log) |
| 585 | if err != nil { |
| 586 | return err |
| 587 | } |
| 588 | |
| 589 | // Save each configuration file |
| 590 | for path, config := range composeManager.Configs() { |
| 591 | localCache, err := localcache.NewCacheLoader().Load(path) |
| 592 | if err != nil { |
| 593 | return err |
| 594 | } |
| 595 | |
| 596 | // Save config |
| 597 | err = loader.Save(path, config) |
| 598 | if err != nil { |
| 599 | return err |
| 600 | } |
| 601 | |
| 602 | // Save generated |
| 603 | err = localCache.Save() |
| 604 | if err != nil { |
| 605 | return errors.Errorf("Error saving generated file: %v", err) |
| 606 | } |
| 607 |
no test coverage detected