mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
refactor: tidy up printing to multiple outputs
This change: - Simplifies printing to multiple outputs. - Adds a comment on why we keep the Print → Score → Submit order when outputting results.
This commit is contained in:
@@ -62,20 +62,21 @@ func (resultsHandler *ResultsHandler) GetResults() *reporthandlingv2.PostureRepo
|
||||
return printerv2.FinalizeResults(resultsHandler.scanData)
|
||||
}
|
||||
|
||||
// HandleResults handle the scan results according to the pre defined interfaces
|
||||
// HandleResults handles all necessary actions for the scan results
|
||||
func (resultsHandler *ResultsHandler) HandleResults() error {
|
||||
for _, printer := range resultsHandler.printerObjs {
|
||||
// First we output the results and then the score, so the
|
||||
// score—a summary of the results—can always be seen at the end
|
||||
// of output
|
||||
printer.ActionPrint(resultsHandler.scanData)
|
||||
printer.Score(resultsHandler.GetRiskScore())
|
||||
}
|
||||
|
||||
// We should submit only after printing results, so a user can see
|
||||
// results at all times, even if submission fails
|
||||
if err := resultsHandler.reporterObj.Submit(resultsHandler.scanData); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printerObjs := resultsHandler.printerObjs
|
||||
|
||||
for i := range printerObjs {
|
||||
printerObjs[i].Score(resultsHandler.GetRiskScore())
|
||||
printerObjs[i].ActionPrint(resultsHandler.scanData)
|
||||
}
|
||||
|
||||
resultsHandler.reporterObj.DisplayReportURL()
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user