@@ -50,26 +50,40 @@ func PrintCheckerPolicies(out io.Writer, flags control.SystemCheckFlags, policie
5050 tf .Format (table )
5151}
5252
53- func countResultPools (resp * control.SystemCheckQueryResp ) int {
53+ func countResultPools (resp * control.SystemCheckQueryResp ) ( int , int ) {
5454 if resp == nil {
55- return 0
55+ return 0 , 0
5656 }
5757
58- poolMap := make (map [string ]struct {})
58+ checkedMap := make (map [string ]struct {})
59+ uncheckedMap := make (map [string ]struct {})
5960 for _ , pool := range resp .Pools {
60- // Don't include pools that were not checked.
6161 if pool .Unchecked () {
62- continue
62+ uncheckedMap [pool .UUID ] = struct {}{}
63+ } else {
64+ checkedMap [pool .UUID ] = struct {}{}
6365 }
64- poolMap [pool .UUID ] = struct {}{}
6566 }
6667 for _ , report := range resp .Reports {
6768 if report .IsRemovedPool () && report .PoolUuid != "" {
68- poolMap [report .PoolUuid ] = struct {}{}
69+ checkedMap [report .PoolUuid ] = struct {}{}
6970 }
7071 }
7172
72- return len (poolMap )
73+ return len (checkedMap ), len (uncheckedMap )
74+ }
75+
76+ func printSystemCheckPoolInfo (out io.Writer , pools []* control.SystemCheckPoolInfo , verbose bool ) {
77+ if verbose {
78+ fmt .Fprintln (out , "\n Per-Pool Checker Info:" )
79+ } else {
80+ fmt .Fprintln (out , "\n Unchecked Pools:" )
81+ }
82+ for _ , pool := range pools {
83+ if verbose || pool .Unchecked () {
84+ fmt .Fprintf (out , " %+v\n " , pool )
85+ }
86+ }
7387}
7488
7589// PrintCheckQueryResp prints the checker results to the console.
@@ -91,26 +105,23 @@ func PrintCheckQueryResp(out io.Writer, resp *control.SystemCheckQueryResp, verb
91105 // should show the number of pools being checked. If the checker has completed,
92106 // we should show the number of unique pools found in the reports.
93107 action := "Checking"
94- poolCount := countResultPools (resp )
108+ checkedCount , uncheckedCount := countResultPools (resp )
95109 if resp .Status == control .SystemCheckStatusCompleted {
96110 action = "Checked"
97111 }
98- if poolCount > 0 {
99- fmt .Fprintf (out , " %s %s\n " , action , english .Plural (poolCount , "pool" , "" ))
112+ if checkedCount > 0 {
113+ fmt .Fprintf (out , " %s %s\n " , action , english .Plural (checkedCount , "pool" , "" ))
100114 }
101115
102- if len (resp .Pools ) > 0 && verbose {
116+ if len (resp .Pools ) > 0 && ( verbose || uncheckedCount > 0 ) {
103117 pools := make ([]* control.SystemCheckPoolInfo , 0 , len (resp .Pools ))
104118 for _ , pool := range resp .Pools {
105119 pools = append (pools , pool )
106120 }
107121 sort .Slice (pools , func (i , j int ) bool {
108122 return pools [i ].UUID < pools [j ].UUID
109123 })
110- fmt .Fprintln (out , "\n Per-Pool Checker Info:" )
111- for _ , pool := range pools {
112- fmt .Fprintf (out , " %+v\n " , pool )
113- }
124+ printSystemCheckPoolInfo (out , pools , verbose )
114125 }
115126
116127 fmt .Fprintln (out )
0 commit comments