Revert "List and set setters in folders recursively"

This commit is contained in:
phani
2020-07-22 13:51:42 -07:00
committed by GitHub
parent 8b9829f222
commit d9fe98a289
9 changed files with 60 additions and 153 deletions

View File

@@ -1,35 +0,0 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package pathutil
import (
"os"
"path/filepath"
"strings"
"sigs.k8s.io/kustomize/kyaml/errors"
)
// SubDirsWithFile takes the root directory path and returns all the paths of
// sub-directories which contain file with input fileName including itself
func SubDirsWithFile(root, fileName string) ([]string, error) {
var res []string
err := filepath.Walk(root,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if strings.HasSuffix(path, fileName) {
if root == "." {
path = root + "/" + path
}
res = append(res, path)
}
return nil
})
if err != nil {
return res, errors.Wrap(err)
}
return res, nil
}