diff --git a/go.mod b/go.mod index f7b78c03e..43fd5167c 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/gobwas/glob v0.2.3 github.com/google/go-cmp v0.6.0 github.com/google/go-jsonnet v0.20.0 - github.com/karrick/godirwalk v1.17.0 github.com/pkg/errors v0.9.1 github.com/posener/complete v1.2.3 github.com/rs/zerolog v1.33.0 diff --git a/go.sum b/go.sum index 8250fe5c7..38fa21b19 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/karrick/godirwalk v1.17.0 h1:b4kY7nqDdioR/6qnbHQyDvmA17u5G1cZ6J+CZXwSWoI= -github.com/karrick/godirwalk v1.17.0/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= diff --git a/pkg/jsonnet/files.go b/pkg/jsonnet/files.go index 9b08cbb6d..c1ffae40d 100644 --- a/pkg/jsonnet/files.go +++ b/pkg/jsonnet/files.go @@ -1,11 +1,11 @@ package jsonnet import ( + "io/fs" "os" "path/filepath" "github.com/gobwas/glob" - "github.com/karrick/godirwalk" ) // FindFiles takes a file / directory and finds all Jsonnet files @@ -21,31 +21,24 @@ func FindFiles(target string, excludes []glob.Glob) ([]string, error) { var files []string - // godirwalk is faster than filepath.Walk, 'cause no os.Stat required - err = godirwalk.Walk(target, &godirwalk.Options{ - Callback: func(rawPath string, de *godirwalk.Dirent) error { - // Normalize slashes for Windows - path := filepath.ToSlash(rawPath) + err = filepath.WalkDir(target, func(path string, d fs.DirEntry, err error) error { + path = filepath.ToSlash(path) + if d.IsDir() { + return nil + } - if de.IsDir() { + // excluded? + for _, g := range excludes { + if g.Match(path) { return nil } + } - // excluded? - for _, g := range excludes { - if g.Match(path) { - return nil - } - } - - // only .jsonnet or .libsonnet - if ext := filepath.Ext(path); ext == ".jsonnet" || ext == ".libsonnet" { - files = append(files, path) - } - return nil - }, - // faster, no sort required - Unsorted: true, + // only .jsonnet or .libsonnet + if ext := filepath.Ext(path); ext == ".jsonnet" || ext == ".libsonnet" { + files = append(files, path) + } + return nil }) if err != nil { return nil, err