filterCustomConfigFiles returns only files that qualify as custom config files. expectedDdevFiles is an optional list of files that are expected to have DDEV markers (core DDEV files). addonFileMap maps file paths to their add-on name for files managed by installed add-ons. Files with DDEV markers t
(files []string, expectedDdevFiles []string, addonFileMap map[string]string, showAll bool)
| 483 | // Files with DDEV markers that are NOT in expectedDdevFiles list are considered unexpected and flagged as custom. |
| 484 | // If showAll is true, add-on files are shown with (add-on <name>) and silenced files with (#ddev-silent-no-warn). |
| 485 | func filterCustomConfigFiles(files []string, expectedDdevFiles []string, addonFileMap map[string]string, showAll bool) []fileInfo { |
| 486 | var out []fileInfo |
| 487 | for _, f := range files { |
| 488 | // Read file once and check for both markers |
| 489 | content, err := os.ReadFile(f) |
| 490 | if err != nil { |
| 491 | // Skip files that don't exist or can't be read |
| 492 | continue |
| 493 | } |
| 494 | |
| 495 | contentStr := string(content) |
| 496 | hasDdevSig := strings.Contains(contentStr, nodeps.DdevFileSignature) |
| 497 | hasSilentNoWarn := strings.Contains(contentStr, nodeps.DdevSilentNoWarn) |
| 498 | |
| 499 | addonName := addonFileMap[f] // empty string if not an add-on file |
| 500 | |
| 501 | if isCustomConfigFile(f, expectedDdevFiles, hasDdevSig, hasSilentNoWarn, showAll) { |
| 502 | out = append(out, fileInfo{ |
| 503 | path: f, |
| 504 | addonName: addonName, |
| 505 | ddevGenerated: hasDdevSig, |
| 506 | silentNoWarn: hasSilentNoWarn, |
| 507 | }) |
| 508 | } |
| 509 | } |
| 510 | return out |
| 511 | } |
| 512 | |
| 513 | // fileLabel returns the display string for a file, appending annotation tags as needed. |
| 514 | func fileLabel(f fileInfo) string { |
no test coverage detected