MCPcopy
hub / github.com/vmware-tanzu/sonobuoy / processNodesWithProcessor

Function processNodesWithProcessor

pkg/client/results/processing.go:214–243  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

212// only if it couldn't open the original directory. Any errors while processing a specific node are logged
213// but not returned.
214func 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

Callers 1

Calls 3

ProcessDirFunction · 0.85
GetNameMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected