(subFS fs.ReadFileFS, dst map[int]*ItemSpec)
| 43 | } |
| 44 | |
| 45 | func loadItemsFromFS(subFS fs.ReadFileFS, dst map[int]*ItemSpec) { |
| 46 | // PluginFiles does not support directory traversal, so use KnownPaths |
| 47 | // when available to enumerate files directly. |
| 48 | if pl, ok := subFS.(fileloader.PathLister); ok { |
| 49 | for _, path := range pl.KnownPaths() { |
| 50 | if !strings.HasPrefix(path, `items/`) || !strings.HasSuffix(path, `.yaml`) { |
| 51 | continue |
| 52 | } |
| 53 | loadItemFileFromFS(subFS, path, dst) |
| 54 | } |
| 55 | return |
| 56 | } |
| 57 | |
| 58 | // Fallback: standard directory walk for FSes that support it. |
| 59 | _ = fs.WalkDir(subFS, `items`, func(path string, d fs.DirEntry, err error) error { |
| 60 | if err != nil || d.IsDir() || !strings.HasSuffix(path, `.yaml`) { |
| 61 | return nil |
| 62 | } |
| 63 | loadItemFileFromFS(subFS, path, dst) |
| 64 | return nil |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | func loadItemFileFromFS(subFS fs.ReadFileFS, path string, dst map[int]*ItemSpec) { |
| 69 | b, err := subFS.ReadFile(path) |
no test coverage detected