MCPcopy Create free account
hub / github.com/ddev/ddev / Init

Method Init

pkg/ddevapp/ddevapp.go:169–204  ·  view source on GitHub ↗

Init populates DdevApp config based on the current working directory. It does not start the containers.

(basePath string)

Source from the content-addressed store, hash-verified

167// Init populates DdevApp config based on the current working directory.
168// It does not start the containers.
169func (app *DdevApp) Init(basePath string) error {
170 defer util.TimeTrackC(fmt.Sprintf("app.Init(%s), RunValidateConfig=%t", basePath, RunValidateConfig))()
171
172 newApp, err := NewApp(basePath, true)
173 if err != nil {
174 return err
175 }
176
177 err = newApp.ValidateConfig()
178 if err != nil {
179 return err
180 }
181
182 *app = *newApp
183 web, err := app.FindContainerByType("web")
184
185 if err != nil {
186 return err
187 }
188
189 if web != nil {
190 containerApproot := web.Labels["com.ddev.approot"]
191 isSameFile, err := fileutil.IsSameFile(containerApproot, app.AppRoot)
192 if err != nil {
193 return err
194 }
195 if !isSameFile {
196 return fmt.Errorf("a project (web container) in %s state already exists for %s that was created at %s", web.State, app.Name, containerApproot).(webContainerExists)
197 }
198 return nil
199 }
200 // Init() is putting together the DdevApp struct, the containers do
201 // not have to exist (app doesn't have to have been started), so the fact
202 // we didn't find any is not an error.
203 return nil
204}
205
206// FindContainerByType will find a container for this site denoted by the containerType if it is available.
207func (app *DdevApp) FindContainerByType(containerType string) (*container.Summary, error) {

Callers 15

TestLoadConfigYamlFileFunction · 0.95
TestPHPOverridesFunction · 0.95
TestPHPConfigFunction · 0.95
TestExtraPackagesFunction · 0.95
TestTimezoneConfigFunction · 0.95
TestMainFunction · 0.95
TestDdevStartFunction · 0.95

Calls 6

FindContainerByTypeMethod · 0.95
TimeTrackCFunction · 0.92
IsSameFileFunction · 0.92
NewAppFunction · 0.85
ValidateConfigMethod · 0.80
ErrorfMethod · 0.80

Tested by 15

TestLoadConfigYamlFileFunction · 0.76
TestPHPOverridesFunction · 0.76
TestPHPConfigFunction · 0.76
TestExtraPackagesFunction · 0.76
TestTimezoneConfigFunction · 0.76
TestMainFunction · 0.76
TestDdevStartFunction · 0.76