MCPcopy Create free account
hub / github.com/ddev/ddev / EnvFiles

Method EnvFiles

pkg/ddevapp/ddevapp.go:1353–1383  ·  view source on GitHub ↗

EnvFiles returns a list of env files for a project. It has to put the .ddev/.env first It has to put the .ddev/.env.* second Env files ending with .example are ignored.

()

Source from the content-addressed store, hash-verified

1351// It has to put the .ddev/.env.* second
1352// Env files ending with .example are ignored.
1353func (app *DdevApp) EnvFiles() ([]string, error) {
1354 origDir, _ := os.Getwd()
1355 defer func() {
1356 _ = os.Chdir(origDir)
1357 }()
1358 err := os.Chdir(app.AppConfDir())
1359 if err != nil {
1360 return nil, err
1361 }
1362 envFiles, err := filepath.Glob(".env.*")
1363 if err != nil {
1364 return []string{}, fmt.Errorf(".env.* in %s: err=%v", app.AppConfDir(), err)
1365 }
1366
1367 var orderedEnvFiles []string
1368
1369 webEnvFile := app.GetConfigPath(".env")
1370 if fileutil.FileExists(webEnvFile) {
1371 orderedEnvFiles = append(orderedEnvFiles, webEnvFile)
1372 }
1373
1374 for _, file := range envFiles {
1375 // Skip .example files
1376 if strings.HasSuffix(file, ".example") {
1377 continue
1378 }
1379 orderedEnvFiles = append(orderedEnvFiles, app.GetConfigPath(file))
1380 }
1381
1382 return orderedEnvFiles, nil
1383}
1384
1385// ProcessHooks executes Tasks defined in Hooks
1386func (app *DdevApp) ProcessHooks(hookName string) error {

Callers 2

fixupComposeYamlFunction · 0.80

Calls 5

AppConfDirMethod · 0.95
GetConfigPathMethod · 0.95
FileExistsFunction · 0.92
ChdirMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected