mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 05:59:22 +00:00
32 lines
No EOL
586 B
Go
32 lines
No EOL
586 B
Go
package fsutils
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func FindYamlInDir(dir string, fileBatches chan<- []string, batchSize int) error {
|
|
files := []string{}
|
|
|
|
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !info.IsDir() && (strings.HasSuffix(info.Name(), ".yaml") || strings.HasSuffix(info.Name(), ".yml")) {
|
|
files = append(files, path)
|
|
if len(files) > batchSize {
|
|
fileBatches <- files
|
|
files = nil
|
|
}
|
|
}
|
|
return nil
|
|
})
|
|
|
|
if len(files) > 0 {
|
|
fileBatches <- files
|
|
}
|
|
|
|
return err
|
|
} |