MCPcopy Index your code
hub / github.com/ddev/ddev / ConfigFileOverrideAction

Method ConfigFileOverrideAction

pkg/ddevapp/apptypes.go:474–501  ·  view source on GitHub ↗

ConfigFileOverrideAction gives a chance for an apptype to override any element of config.yaml that it needs to

(overrideExistingConfig bool)

Source from the content-addressed store, hash-verified

472// ConfigFileOverrideAction gives a chance for an apptype to override any element
473// of config.yaml that it needs to
474func (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.

Callers 5

PromptForConfigMethod · 0.95
TestConfigOverrideActionFunction · 0.80
PrepareMethod · 0.80
handleMainConfigArgsFunction · 0.80

Calls 4

ConfigExistsMethod · 0.95
GetExistingDBTypeMethod · 0.95
SuccessFunction · 0.92
WarningFunction · 0.92

Tested by 2

TestConfigOverrideActionFunction · 0.64