ConfigFileOverrideAction gives a chance for an apptype to override any element of config.yaml that it needs to
(overrideExistingConfig bool)
| 472 | // ConfigFileOverrideAction gives a chance for an apptype to override any element |
| 473 | // of config.yaml that it needs to |
| 474 | func (app *DdevApp) ConfigFileOverrideAction(overrideExistingConfig bool) error { |
| 475 | if appFuncs, ok := appTypeMatrix[app.Type]; ok && appFuncs.configOverrideAction != nil && (overrideExistingConfig || !app.ConfigExists()) { |
| 476 | origDB := app.Database |
| 477 | err := appFuncs.configOverrideAction(app) |
| 478 | if err != nil { |
| 479 | return err |
| 480 | } |
| 481 | // If the override function has changed the database type |
| 482 | // check to make sure that there's not one already existing |
| 483 | if origDB != app.Database { |
| 484 | // We can't upgrade database if it already exists |
| 485 | dbType, err := app.GetExistingDBType() |
| 486 | if err != nil { |
| 487 | return err |
| 488 | } |
| 489 | recommendedDBType := app.Database.Type + ":" + app.Database.Version |
| 490 | if dbType == "" { |
| 491 | // Assume that we don't have a database yet |
| 492 | util.Success("Configuring %s project with database type '%s'", app.Type, recommendedDBType) |
| 493 | } else if dbType != recommendedDBType { |
| 494 | util.Warning("%s project already has database type set to non-recommended: %s, not changing it to recommended %s", app.Type, dbType, recommendedDBType) |
| 495 | app.Database = origDB |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | return nil |
| 501 | } |
| 502 | |
| 503 | // PostConfigAction gives a chance for an apptype to override do something at |
| 504 | // the end of ddev config. |