MCPcopy Index your code
hub / github.com/devspace-sh/devspace / initDockerCompose

Method initDockerCompose

cmd/init.go:550–621  ·  view source on GitHub ↗
(f factory.Factory, composePath string)

Source from the content-addressed store, hash-verified

548}
549
550func (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

Callers 1

RunMethod · 0.95

Calls 14

LoadMethod · 0.95
ConfigsMethod · 0.95
LoadDockerComposeProjectFunction · 0.92
GetServiceSyncPathsFunction · 0.92
NewComposeManagerFunction · 0.92
NewCacheLoaderFunction · 0.92
SaveFunction · 0.92
getProjectNameFunction · 0.85
appendToIgnoreFileFunction · 0.85
annotateConfigFunction · 0.85
QuestionMethod · 0.65
SaveMethod · 0.65

Tested by

no test coverage detected