Implement ExportData to filter json fields

In order to filter json fields, the `ExportData` interface needed to be implemented with logic that iterated on the selected fields.
This commit is contained in:
Andy Feller 2024-05-14 09:49:07 -04:00
parent 8a1995c98d
commit ac5510362b

View file

@ -6,6 +6,7 @@ import (
"time"
"github.com/cli/cli/v2/api"
"github.com/cli/cli/v2/pkg/cmdutil"
)
type check struct {
@ -28,6 +29,10 @@ type checkCounts struct {
Canceled int
}
func (ch *check) ExportData(fields []string) map[string]interface{} {
return cmdutil.StructExportData(ch, fields)
}
func aggregateChecks(checkContexts []api.CheckContext, requiredChecks bool) (checks []check, counts checkCounts) {
for _, c := range eliminateDuplicates(checkContexts) {
if requiredChecks && !c.IsRequired {