Skip to content

Commit 5f6264d

Browse files
committed
add excludedDirs optional argument
Signed-off-by: Mikhail Scherba <mikhail.scherba@flant.com>
1 parent a09a79d commit 5f6264d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/utils/file/file.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log/slog"
66
"os"
77
"path/filepath"
8+
"slices"
89
"strings"
910

1011
"github.com/deckhouse/deckhouse/pkg/log"
@@ -32,16 +33,17 @@ func CheckExecutablePermissions(f os.FileInfo) error {
3233

3334
// RecursiveGetExecutablePaths finds recursively all executable files
3435
// inside a dir directory. Hidden directories and files are ignored.
35-
func RecursiveGetExecutablePaths(dir string) ([]string, error) {
36+
func RecursiveGetExecutablePaths(dir string, excludedDirs ...string) ([]string, error) {
3637
paths := make([]string, 0)
38+
excludedDirs = append(excludedDirs, "lib")
3739
err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
3840
if err != nil {
3941
return err
4042
}
4143

4244
if f.IsDir() {
4345
// Skip hidden and lib directories inside initial directory
44-
if strings.HasPrefix(f.Name(), ".") || f.Name() == "lib" {
46+
if strings.HasPrefix(f.Name(), ".") || slices.Contains(excludedDirs, f.Name()) {
4547
return filepath.SkipDir
4648
}
4749

0 commit comments

Comments
 (0)