@@ -123,7 +123,10 @@ func PrintObjectTree(tree *tree.ObjectTree, w io.Writer) {
123
123
addObjectRow ("" , tbl , tree , tree .GetRoot ())
124
124
125
125
// Prints the output table
126
- tbl .Render ()
126
+ if err := tbl .Render (); err != nil {
127
+ fmt .Printf ("Error rendering table: %v" , err )
128
+ os .Exit (1 )
129
+ }
127
130
}
128
131
129
132
// PrintObjectTreeV1Beta1 prints the cluster status to stdout.
@@ -136,7 +139,10 @@ func PrintObjectTreeV1Beta1(tree *tree.ObjectTree) {
136
139
addObjectRowV1Beta1 ("" , tbl , tree , tree .GetRoot ())
137
140
138
141
// Prints the output table
139
- tbl .Render ()
142
+ if err := tbl .Render (); err != nil {
143
+ fmt .Printf ("Error rendering table: %v" , err )
144
+ os .Exit (1 )
145
+ }
140
146
}
141
147
142
148
// addObjectRow add a row for a given object, and recursively for all the object's children.
@@ -179,7 +185,7 @@ func addObjectRow(prefix string, tbl *tablewriter.Table, objectTree *tree.Object
179
185
if len (msg ) >= 1 {
180
186
msg0 = msg [0 ]
181
187
}
182
- tbl .Append ([]string {
188
+ if err := tbl .Append ([]string {
183
189
fmt .Sprintf ("%s%s" , gray .Sprint (prefix ), name ),
184
190
rowDescriptor .replicas ,
185
191
rowDescriptor .availableCounters ,
@@ -188,11 +194,14 @@ func addObjectRow(prefix string, tbl *tablewriter.Table, objectTree *tree.Object
188
194
rowDescriptor .status ,
189
195
rowDescriptor .reason ,
190
196
rowDescriptor .age ,
191
- msg0 })
197
+ msg0 }); err != nil {
198
+ fmt .Printf ("Error appending row: %v" , err )
199
+ os .Exit (1 )
200
+ }
192
201
193
202
multilinePrefix := getRootMultiLineObjectPrefix (obj , objectTree )
194
203
for _ , m := range msg [1 :] {
195
- tbl .Append ([]string {
204
+ if err := tbl .Append ([]string {
196
205
gray .Sprint (multilinePrefix ),
197
206
"" ,
198
207
"" ,
@@ -201,7 +210,10 @@ func addObjectRow(prefix string, tbl *tablewriter.Table, objectTree *tree.Object
201
210
"" ,
202
211
"" ,
203
212
"" ,
204
- m })
213
+ m }); err != nil {
214
+ fmt .Printf ("Error appending row: %v" , err )
215
+ os .Exit (1 )
216
+ }
205
217
}
206
218
207
219
// If it is required to show all the conditions for the object, add a row for each object's conditions.
@@ -259,13 +271,16 @@ func addObjectRowV1Beta1(prefix string, tbl *tablewriter.Table, objectTree *tree
259
271
// Add the row representing the object that includes
260
272
// - The row name with the tree view prefix.
261
273
// - The object's ready condition.
262
- tbl .Append ([]string {
274
+ if err := tbl .Append ([]string {
263
275
fmt .Sprintf ("%s%s" , gray .Sprint (prefix ), name ),
264
276
readyDescriptor .readyColor .Sprint (readyDescriptor .status ),
265
277
readyDescriptor .readyColor .Sprint (readyDescriptor .severity ),
266
278
readyDescriptor .readyColor .Sprint (readyDescriptor .reason ),
267
279
readyDescriptor .age ,
268
- readyDescriptor .message })
280
+ readyDescriptor .message }); err != nil {
281
+ fmt .Printf ("Error appending row: %v" , err )
282
+ os .Exit (1 )
283
+ }
269
284
270
285
// If it is required to show all the conditions for the object, add a row for each object's conditions.
271
286
if tree .IsShowConditionsObject (obj ) {
@@ -330,7 +345,7 @@ func addOtherConditions(prefix string, tbl *tablewriter.Table, objectTree *tree.
330
345
if len (msg ) >= 1 {
331
346
msg0 = msg [0 ]
332
347
}
333
- tbl .Append ([]string {
348
+ if err := tbl .Append ([]string {
334
349
fmt .Sprintf ("%s%s" , gray .Sprint (childPrefix ), cyan .Sprint (condition .Type )),
335
350
"" ,
336
351
"" ,
@@ -339,10 +354,13 @@ func addOtherConditions(prefix string, tbl *tablewriter.Table, objectTree *tree.
339
354
c .Sprint (status ),
340
355
reason ,
341
356
age ,
342
- msg0 })
357
+ msg0 }); err != nil {
358
+ fmt .Printf ("Error appending row: %v" , err )
359
+ os .Exit (1 )
360
+ }
343
361
344
362
for _ , m := range msg [1 :] {
345
- tbl .Append ([]string {
363
+ if err := tbl .Append ([]string {
346
364
gray .Sprint (getMultilineConditionPrefix (childPrefix )),
347
365
"" ,
348
366
"" ,
@@ -351,7 +369,10 @@ func addOtherConditions(prefix string, tbl *tablewriter.Table, objectTree *tree.
351
369
"" ,
352
370
"" ,
353
371
"" ,
354
- m })
372
+ m }); err != nil {
373
+ fmt .Printf ("Error appending row: %v" , err )
374
+ os .Exit (1 )
375
+ }
355
376
}
356
377
}
357
378
}
@@ -373,13 +394,16 @@ func addOtherConditionsV1Beta1(prefix string, tbl *tablewriter.Table, objectTree
373
394
otherCondition := otherConditions [i ]
374
395
otherDescriptor := newV1Beta1ConditionDescriptor (otherCondition )
375
396
otherConditionPrefix := getChildPrefix (prefix + childrenPipe + filler , i , len (otherConditions ))
376
- tbl .Append ([]string {
397
+ if err := tbl .Append ([]string {
377
398
fmt .Sprintf ("%s%s" , gray .Sprint (otherConditionPrefix ), cyan .Sprint (otherCondition .Type )),
378
399
otherDescriptor .readyColor .Sprint (otherDescriptor .status ),
379
400
otherDescriptor .readyColor .Sprint (otherDescriptor .severity ),
380
401
otherDescriptor .readyColor .Sprint (otherDescriptor .reason ),
381
402
otherDescriptor .age ,
382
- otherDescriptor .message })
403
+ otherDescriptor .message }); err != nil {
404
+ fmt .Printf ("Error appending row: %v" , err )
405
+ os .Exit (1 )
406
+ }
383
407
}
384
408
}
385
409
0 commit comments