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

Method ValidateConfig

pkg/ddevapp/config.go:498–621  ·  view source on GitHub ↗

ValidateConfig ensures the configuration meets ddev's requirements.

()

Source from the content-addressed store, hash-verified

496
497// ValidateConfig ensures the configuration meets ddev's requirements.
498func (app *DdevApp) ValidateConfig() error {
499 // Skip project validation on request.
500 if !RunValidateConfig {
501 return nil
502 }
503
504 // Validate ddev version constraint, if any
505 if app.DdevVersionConstraint != "" {
506 err := CheckDdevVersionConstraint(app.DdevVersionConstraint, fmt.Sprintf("unable to start the '%s' project", app.Name), "or update the `ddev_version_constraint` in your .ddev/config.yaml file")
507 if err != nil {
508 return err
509 }
510 }
511
512 // Validate project name
513 if err := ValidateProjectName(app.Name); err != nil {
514 return err
515 }
516
517 // Validate docroot
518 if err := ValidateDocroot(app.Docroot); err != nil {
519 return err
520 }
521
522 // Skip any validation below this check if there is nothing to validate
523 if err := CheckForMissingProjectFiles(app); err != nil {
524 // Do not return an error here because not all DDEV commands should be stopped by this check
525 // It matters when you start a project, but not when you stop or delete it
526 // This check is reused elsewhere where appropriate
527 return nil
528 }
529
530 // Validate hostnames
531 for _, hn := range app.GetHostnames() {
532 // If they have provided "*.<hostname>" then ignore the *. part.
533 hn = strings.TrimPrefix(hn, "*.")
534 if hn == nodeps.DdevDefaultTLD {
535 return fmt.Errorf("wildcarding the full hostname\nor using 'ddev.site' as FQDN for the project %s is not allowed\nbecause other projects would not work in that case", app.Name)
536 }
537 if !hostRegex.MatchString(hn) {
538 return fmt.Errorf("the %s project has an invalid hostname: '%s', see https://en.wikipedia.org/wiki/Hostname#Syntax for valid hostname requirements", app.Name, hn).(invalidHostname)
539 }
540 }
541
542 // Validate apptype
543 if !IsValidAppType(app.Type) {
544 return fmt.Errorf("the %s project has an invalid app type: %s", app.Name, app.Type).(invalidAppType)
545 }
546
547 // Validate PHP version
548 if !nodeps.IsValidPHPVersion(app.PHPVersion) {
549 return fmt.Errorf("the %s project has an unsupported PHP version: %s, DDEV only supports the following versions: %v", app.Name, app.PHPVersion, nodeps.GetValidPHPVersions()).(invalidPHPVersion)
550 }
551
552 // Validate webserver type
553 if !nodeps.IsValidWebserverType(app.WebserverType) {
554 return fmt.Errorf("the %s project has an unsupported webserver type: %s, DDEV (%s) only supports the following webserver types: %s", app.Name, app.WebserverType, runtime.GOARCH, nodeps.GetValidWebserverTypes()).(invalidWebserverType)
555 }

Callers 5

PromptForConfigMethod · 0.95
TestConfigValidateFunction · 0.80
InitMethod · 0.80
handleMainConfigArgsFunction · 0.80

Calls 15

GetHostnamesMethod · 0.95
IsValidPHPVersionFunction · 0.92
GetValidPHPVersionsFunction · 0.92
IsValidWebserverTypeFunction · 0.92
GetValidWebserverTypesFunction · 0.92
IsValidOmitContainersFunction · 0.92
GetValidOmitContainersFunction · 0.92
IsValidDatabaseVersionFunction · 0.92
GetValidMariaDBVersionsFunction · 0.92
GetValidMySQLVersionsFunction · 0.92
GetValidPostgresVersionsFunction · 0.92
ValidatePortFunction · 0.92

Tested by 1

TestConfigValidateFunction · 0.64