processNodesWithProcessor is called to invoke ProcessDir on each node-specific directory contained underneath the given dir. The directory is assumed to be either the results directory or errors directory which should have the nodes as subdirectories. It returns an item for each node processed and a
(p plugin.Interface, baseDir, dir string, processor postProcessor, selector fileSelector)
| 212 | // only if it couldn't open the original directory. Any errors while processing a specific node are logged |
| 213 | // but not returned. |
| 214 | func processNodesWithProcessor(p plugin.Interface, baseDir, dir string, processor postProcessor, selector fileSelector) ([]Item, error) { |
| 215 | pdir := path.Join(baseDir, PluginsDir, p.GetName()) |
| 216 | |
| 217 | nodeDirs, err := os.ReadDir(dir) |
| 218 | if err != nil && !os.IsNotExist(err) { |
| 219 | return []Item{}, err |
| 220 | } |
| 221 | |
| 222 | results := []Item{} |
| 223 | |
| 224 | for _, nodeDirInfo := range nodeDirs { |
| 225 | if !nodeDirInfo.IsDir() { |
| 226 | continue |
| 227 | } |
| 228 | nodeName := filepath.Base(nodeDirInfo.Name()) |
| 229 | nodeItem := Item{ |
| 230 | Name: nodeName, |
| 231 | Metadata: map[string]string{MetadataTypeKey: MetadataTypeNode}, |
| 232 | } |
| 233 | items, err := ProcessDir(p, pdir, filepath.Join(dir, nodeName), processor, selector) |
| 234 | nodeItem.Items = items |
| 235 | if err != nil { |
| 236 | logrus.Warningf("Error processing results entries for node %v, plugin %v: %v", nodeDirInfo.Name(), p.GetName(), err) |
| 237 | } |
| 238 | |
| 239 | results = append(results, nodeItem) |
| 240 | } |
| 241 | |
| 242 | return results, nil |
| 243 | } |
| 244 | |
| 245 | // processPluginWithProcessor will apply the processor to the chosen files. It will also process the <plugin>/errors |
| 246 | // directory for errors. One item will be returned with the results already aggregated. All errors encountered will be |
no test coverage detected