MCPcopy Create free account
hub / github.com/diillson/chatcli / readConfigFiles

Function readConfigFiles

operator/controllers/source_controller.go:807–850  ·  view source on GitHub ↗

readConfigFiles reads deployment-related config files.

(localPath string, configFiles []string)

Source from the content-addressed store, hash-verified

805
806// readConfigFiles reads deployment-related config files.
807func readConfigFiles(localPath string, configFiles []string) []ConfigFileContent {
808 configs := make([]ConfigFileContent, 0, len(configFiles))
809
810 important := []string{"Dockerfile", "values.yaml", "Chart.yaml"}
811 for _, cf := range configFiles {
812 isImportant := false
813 for _, imp := range important {
814 if strings.Contains(cf, imp) {
815 isImportant = true
816 break
817 }
818 }
819 if !isImportant {
820 continue
821 }
822
823 fullPath := filepath.Join(localPath, cf)
824 // Confinement: config paths come from our own index, but re-check
825 // that the join did not escape the clone root before reading.
826 if !strings.HasPrefix(filepath.Clean(fullPath)+string(os.PathSeparator), filepath.Clean(localPath)+string(os.PathSeparator)) {
827 continue
828 }
829 data, err := os.ReadFile(fullPath) // #nosec G304 -- path confined to the repo clone root above
830 if err != nil {
831 continue
832 }
833
834 content := string(data)
835 if len(content) > 2000 {
836 content = content[:2000] + "\n... (truncated)"
837 }
838
839 configs = append(configs, ConfigFileContent{
840 FilePath: cf,
841 Content: content,
842 })
843
844 if len(configs) >= 3 {
845 break
846 }
847 }
848
849 return configs
850}
851
852func buildSourceCodeSummary(ctx *SourceCodeContext) string {
853 var parts []string

Callers 2

TestReadConfigFilesFunction · 0.85
BuildSourceContextMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestReadConfigFilesFunction · 0.68