in custard/pkg/config/config.go [205:230]
func (c *Config) FindSetupFiles(paths []string) (*map[string]CISetup, []string) {
var errors []string
setups := make(map[string]CISetup, len(paths))
for _, path := range paths {
setup := make(CISetup, len(c.CISetupDefaults))
for k, v := range c.CISetupDefaults {
setup[k] = v
}
setupFile := filepath.Join(path, c.CISetupFileName)
if c.CISetupFileName != "" && fileExists(setupFile) {
// This mutates `setup` so there's no need to reassign it.
// It keeps the default values if they're not in the JSON file.
err := readJsonc(setupFile, &setup)
if err != nil {
errors = append(errors, fmt.Sprintf("%v: %v", setupFile, err.Error()))
continue
}
}
validationErrors := c.ValidateCISetup(setup)
for _, msg := range validationErrors {
errors = append(errors, fmt.Sprintf("%v: %v", setupFile, msg))
}
setups[path] = setup
}
return &setups, errors
}