@@ -282,44 +282,31 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error
282
282
errorSuggestions := 0
283
283
if len (errorMarkers ) > 0 {
284
284
fmt .Fprintln (out , "Errors:" )
285
- for _ , marker := range errorMarkers {
286
- fmt .Fprintln (out , indent + "* " + marker .Message )
287
- if len (marker .Suggestion ) > 0 {
288
- errorSuggestions ++
289
- if d .Suggest {
290
- switch s := marker .Suggestion .String (); {
291
- case strings .Contains (s , "\n " ):
292
- fmt .Fprintln (out )
293
- for _ , line := range strings .Split (s , "\n " ) {
294
- fmt .Fprintln (out , indent + " " + line )
295
- }
296
- case len (s ) > 0 :
297
- fmt .Fprintln (out , indent + " try: " + s )
298
- }
299
- }
300
- }
301
- }
285
+ errorSuggestions += printMarkerSuggestions (errorMarkers , d .Suggest , out , indent )
302
286
}
303
287
304
288
warningMarkers := allMarkers .BySeverity (osgraph .WarningSeverity )
305
289
if len (warningMarkers ) > 0 {
306
290
if d .Suggest {
291
+ // add linebreak between Errors list and Warnings list
292
+ if len (errorMarkers ) > 0 {
293
+ fmt .Fprintln (out )
294
+ }
307
295
fmt .Fprintln (out , "Warnings:" )
308
296
}
309
- for _ , marker := range warningMarkers {
310
- if d .Suggest {
311
- fmt .Fprintln (out , indent + "* " + marker .Message )
312
- switch s := marker .Suggestion .String (); {
313
- case strings .Contains (s , "\n " ):
314
- fmt .Fprintln (out )
315
- for _ , line := range strings .Split (s , "\n " ) {
316
- fmt .Fprintln (out , indent + " " + line )
317
- }
318
- case len (s ) > 0 :
319
- fmt .Fprintln (out , indent + " try: " + s )
320
- }
297
+ printMarkerSuggestions (warningMarkers , d .Suggest , out , indent )
298
+ }
299
+
300
+ infoMarkers := allMarkers .BySeverity (osgraph .InfoSeverity )
301
+ if len (infoMarkers ) > 0 {
302
+ if d .Suggest {
303
+ // add linebreak between Warnings list and Info List
304
+ if len (warningMarkers ) > 0 || len (errorMarkers ) > 0 {
305
+ fmt .Fprintln (out )
321
306
}
307
+ fmt .Fprintln (out , "Info:" )
322
308
}
309
+ printMarkerSuggestions (infoMarkers , d .Suggest , out , indent )
323
310
}
324
311
325
312
// We print errors by default and warnings if -v is used. If we get none,
@@ -362,6 +349,32 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error
362
349
})
363
350
}
364
351
352
+ // printMarkerSuggestions prints a formatted list of marker suggestions
353
+ // and returns the amount of suggestions printed
354
+ func printMarkerSuggestions (markers []osgraph.Marker , suggest bool , out * tabwriter.Writer , indent string ) int {
355
+ suggestionAmount := 0
356
+ for _ , marker := range markers {
357
+ if len (marker .Suggestion ) > 0 {
358
+ suggestionAmount ++
359
+ }
360
+ if len (marker .Suggestion ) > 0 || len (marker .Message ) > 0 {
361
+ if suggest {
362
+ fmt .Fprintln (out , indent + "* " + marker .Message )
363
+ switch s := marker .Suggestion .String (); {
364
+ case strings .Contains (s , "\n " ):
365
+ fmt .Fprintln (out )
366
+ for _ , line := range strings .Split (s , "\n " ) {
367
+ fmt .Fprintln (out , indent + " " + line )
368
+ }
369
+ case len (s ) > 0 :
370
+ fmt .Fprintln (out , indent + " try: " + s )
371
+ }
372
+ }
373
+ }
374
+ }
375
+ return suggestionAmount
376
+ }
377
+
365
378
func createForbiddenMarkers (forbiddenResources sets.String ) []osgraph.Marker {
366
379
markers := []osgraph.Marker {}
367
380
for forbiddenResource := range forbiddenResources {
0 commit comments