UpdateGlobalProjectList updates any information about project that is tracked in global project list: - approot - configured host ports Checks that configured host ports are not already reserved by another project
()
| 327 | // Checks that configured host ports are not already |
| 328 | // reserved by another project |
| 329 | func (app *DdevApp) UpdateGlobalProjectList() error { |
| 330 | portsToReserve := []string{} |
| 331 | if app.HostDBPort != "" { |
| 332 | portsToReserve = append(portsToReserve, app.HostDBPort) |
| 333 | } |
| 334 | if app.HostWebserverPort != "" { |
| 335 | portsToReserve = append(portsToReserve, app.HostWebserverPort) |
| 336 | } |
| 337 | if app.HostHTTPSPort != "" { |
| 338 | portsToReserve = append(portsToReserve, app.HostHTTPSPort) |
| 339 | } |
| 340 | |
| 341 | if len(portsToReserve) > 0 { |
| 342 | err := globalconfig.CheckHostPortsAvailable(app.Name, portsToReserve) |
| 343 | if err != nil { |
| 344 | return err |
| 345 | } |
| 346 | } |
| 347 | err := globalconfig.ReservePorts(app.Name, portsToReserve) |
| 348 | if err != nil { |
| 349 | return err |
| 350 | } |
| 351 | err = globalconfig.SetProjectAppRoot(app.Name, app.AppRoot) |
| 352 | if err != nil { |
| 353 | return err |
| 354 | } |
| 355 | |
| 356 | return nil |
| 357 | } |
| 358 | |
| 359 | // ReadConfig reads project configuration from the config.yaml file |
| 360 | // It does not attempt to set default values; that's NewApp's job. |