mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-20 02:17:01 +00:00
Merge c691d7e07a into e60892483e
This commit is contained in:
commit
380c968e47
1 changed files with 40 additions and 13 deletions
|
|
@ -40,6 +40,24 @@ func isIgnored(path string, ignoreFilePatterns []string) (bool, error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkFile(path string, info os.FileInfo, files chan<- string, ignoreFilePatterns []string) error {
|
||||||
|
if !isYAMLFile(info) && !isJSONFile(info) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ignored, err := isIgnored(path, ignoreFilePatterns)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if ignored {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
files <- path
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func findFilesInFolders(ctx context.Context, paths []string, ignoreFilePatterns []string) (chan string, chan error) {
|
func findFilesInFolders(ctx context.Context, paths []string, ignoreFilePatterns []string) (chan string, chan error) {
|
||||||
files := make(chan string)
|
files := make(chan string)
|
||||||
errors := make(chan error)
|
errors := make(chan error)
|
||||||
|
|
@ -59,21 +77,30 @@ func findFilesInFolders(ctx context.Context, paths []string, ignoreFilePatterns
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isYAMLFile(i) && !isJSONFile(i) {
|
// follow top-level directory symlinks
|
||||||
return nil
|
if i.Mode()&os.ModeSymlink != 0 {
|
||||||
|
linkInfo, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if linkInfo.IsDir() {
|
||||||
|
evalPath, err := filepath.EvalSymlinks(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
filepath.Walk(evalPath, func(p string, i os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkFile(p, i, files, ignoreFilePatterns)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ignored, err := isIgnored(p, ignoreFilePatterns)
|
return checkFile(p, i, files, ignoreFilePatterns)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if ignored {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
files <- p
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue