in internal/resources/fetching/fetchers/k8s/glob_matching.go [41:77]
func (globs Globs) Expand() ([]string, error) {
matches := []string{""} // accumulate here
for _, glob := range globs {
var hits []string
hitMap := map[string]bool{}
for _, match := range matches {
paths, err := filepath.Glob(match + glob)
if err != nil {
return nil, err
}
for _, path := range paths {
err = filepath.Walk(path, func(path string, _ os.FileInfo, err error) error {
if err != nil {
return err
}
// save deduped match from current iteration
if _, ok := hitMap[path]; !ok {
hits = append(hits, path)
hitMap[path] = true
}
return nil
})
if err != nil {
return nil, err
}
}
}
matches = hits
}
// fix up return value for nil input
if globs == nil && len(matches) > 0 && matches[0] == "" {
matches = matches[1:]
}
return matches, nil
}