1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-10 01:46:55 +00:00
kyverno/cmd/cli/kubectl-kyverno/utils/output/table/table.go
Charles-Edouard Brétéché c93ac4655c
refactor: cli test command (#8212)
* code changes

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* test changes

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-09-04 09:34:27 +00:00

43 lines
813 B
Go

package table
type Table struct {
RawRows []Row
}
func (t *Table) Rows(detailed bool) interface{} {
if detailed {
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"`
Reason string `header:"reason"`
}
type Row struct {
CompactRow `header:"inline"`
Message string `header:"message"`
}