2023-07-06 13:48:19 +02:00
|
|
|
package table
|
|
|
|
|
|
|
|
type Table struct {
|
|
|
|
RawRows []Row
|
|
|
|
}
|
|
|
|
|
2023-07-31 17:15:47 +03:00
|
|
|
func (t *Table) Rows(detailed bool) interface{} {
|
|
|
|
if detailed {
|
2023-07-06 13:48:19 +02:00
|
|
|
return t.RawRows
|
|
|
|
}
|
|
|
|
var rows []CompactRow
|
|
|
|
for _, row := range t.RawRows {
|
|
|
|
rows = append(rows, row.CompactRow)
|
|
|
|
}
|
|
|
|
return rows
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Table) AddFailed(rows ...Row) {
|
|
|
|
for _, row := range rows {
|
|
|
|
if row.IsFailure {
|
|
|
|
t.RawRows = append(t.RawRows, row)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Table) Add(rows ...Row) {
|
|
|
|
t.RawRows = append(t.RawRows, rows...)
|
|
|
|
}
|
|
|
|
|
|
|
|
type CompactRow struct {
|
|
|
|
IsFailure bool
|
|
|
|
ID int `header:"id"`
|
|
|
|
Policy string `header:"policy"`
|
|
|
|
Rule string `header:"rule"`
|
|
|
|
Resource string `header:"resource"`
|
|
|
|
Result string `header:"result"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Row struct {
|
|
|
|
CompactRow `header:"inline"`
|
|
|
|
Message string `header:"message"`
|
|
|
|
}
|