in pkg/gcv/configs/file.go [112:137]
func (p *localPath) ReadAll(ctx context.Context, predicates ...readPredicate) ([]File, error) {
var files []File
visit := func(path string, f os.FileInfo, err error) error {
if err != nil {
return errors.Wrapf(err, "error visiting path %s", path)
}
if f.IsDir() {
return nil
}
if !matchesPredicates(path, predicates) {
return nil
}
content, err := os.ReadFile(path)
if err != nil {
return errors.Wrapf(err, "failed to read %s", path)
}
files = append(files, File{Path: path, Content: content})
return nil
}
err := filepath.Walk(p.path, visit)
if err != nil {
return nil, errors.Wrapf(err, "failed to read files in %s", p.path)
}
return files, nil
}