-
Notifications
You must be signed in to change notification settings - Fork 262
/
summary_severity.go
44 lines (37 loc) · 1.18 KB
/
summary_severity.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package controldisplay
import (
"github.com/turbot/go-kit/helpers"
"github.com/turbot/steampipe/pkg/control/controlexecute"
)
type SummarySeverityRenderer struct {
resultTree *controlexecute.ExecutionTree
width int
}
func NewSummarySeverityRenderer(resultTree *controlexecute.ExecutionTree, width int) *SummarySeverityRenderer {
return &SummarySeverityRenderer{
resultTree: resultTree,
width: width,
}
}
func (r *SummarySeverityRenderer) Render() []string {
availableWidth := r.width
// render the critical line
criticalSeverityRow := NewSummarySeverityRowRenderer(r.resultTree, availableWidth, "critical").Render()
criticalWidth := helpers.PrintableLength(criticalSeverityRow)
// if there is a critical line, use this to set the max width
if criticalWidth > 0 {
availableWidth = criticalWidth
}
// render the high line
highSeverityRow := NewSummarySeverityRowRenderer(r.resultTree, availableWidth, "high").Render()
highWidth := helpers.PrintableLength(highSeverityRow)
// build the severity block
var strs []string
if criticalWidth > 0 {
strs = append(strs, criticalSeverityRow)
}
if highWidth > 0 {
strs = append(strs, highSeverityRow)
}
return strs
}