Init populates DdevApp config based on the current working directory. It does not start the containers.
(basePath string)
| 167 | // Init populates DdevApp config based on the current working directory. |
| 168 | // It does not start the containers. |
| 169 | func (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. |
| 207 | func (app *DdevApp) FindContainerByType(containerType string) (*container.Summary, error) { |