@@ -123,7 +123,10 @@ func PrintObjectTree(tree *tree.ObjectTree, w io.Writer) {
123123 addObjectRow ("" , tbl , tree , tree .GetRoot ())
124124
125125 // 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+ }
127130}
128131
129132// PrintObjectTreeV1Beta1 prints the cluster status to stdout.
@@ -136,7 +139,10 @@ func PrintObjectTreeV1Beta1(tree *tree.ObjectTree) {
136139 addObjectRowV1Beta1 ("" , tbl , tree , tree .GetRoot ())
137140
138141 // 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+ }
140146}
141147
142148// 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
179185 if len (msg ) >= 1 {
180186 msg0 = msg [0 ]
181187 }
182- tbl .Append ([]string {
188+ if err := tbl .Append ([]string {
183189 fmt .Sprintf ("%s%s" , gray .Sprint (prefix ), name ),
184190 rowDescriptor .replicas ,
185191 rowDescriptor .availableCounters ,
@@ -188,11 +194,14 @@ func addObjectRow(prefix string, tbl *tablewriter.Table, objectTree *tree.Object
188194 rowDescriptor .status ,
189195 rowDescriptor .reason ,
190196 rowDescriptor .age ,
191- msg0 })
197+ msg0 }); err != nil {
198+ fmt .Printf ("Error appending row: %v" , err )
199+ os .Exit (1 )
200+ }
192201
193202 multilinePrefix := getRootMultiLineObjectPrefix (obj , objectTree )
194203 for _ , m := range msg [1 :] {
195- tbl .Append ([]string {
204+ if err := tbl .Append ([]string {
196205 gray .Sprint (multilinePrefix ),
197206 "" ,
198207 "" ,
@@ -201,7 +210,10 @@ func addObjectRow(prefix string, tbl *tablewriter.Table, objectTree *tree.Object
201210 "" ,
202211 "" ,
203212 "" ,
204- m })
213+ m }); err != nil {
214+ fmt .Printf ("Error appending row: %v" , err )
215+ os .Exit (1 )
216+ }
205217 }
206218
207219 // 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
259271 // Add the row representing the object that includes
260272 // - The row name with the tree view prefix.
261273 // - The object's ready condition.
262- tbl .Append ([]string {
274+ if err := tbl .Append ([]string {
263275 fmt .Sprintf ("%s%s" , gray .Sprint (prefix ), name ),
264276 readyDescriptor .readyColor .Sprint (readyDescriptor .status ),
265277 readyDescriptor .readyColor .Sprint (readyDescriptor .severity ),
266278 readyDescriptor .readyColor .Sprint (readyDescriptor .reason ),
267279 readyDescriptor .age ,
268- readyDescriptor .message })
280+ readyDescriptor .message }); err != nil {
281+ fmt .Printf ("Error appending row: %v" , err )
282+ os .Exit (1 )
283+ }
269284
270285 // If it is required to show all the conditions for the object, add a row for each object's conditions.
271286 if tree .IsShowConditionsObject (obj ) {
@@ -330,7 +345,7 @@ func addOtherConditions(prefix string, tbl *tablewriter.Table, objectTree *tree.
330345 if len (msg ) >= 1 {
331346 msg0 = msg [0 ]
332347 }
333- tbl .Append ([]string {
348+ if err := tbl .Append ([]string {
334349 fmt .Sprintf ("%s%s" , gray .Sprint (childPrefix ), cyan .Sprint (condition .Type )),
335350 "" ,
336351 "" ,
@@ -339,10 +354,13 @@ func addOtherConditions(prefix string, tbl *tablewriter.Table, objectTree *tree.
339354 c .Sprint (status ),
340355 reason ,
341356 age ,
342- msg0 })
357+ msg0 }); err != nil {
358+ fmt .Printf ("Error appending row: %v" , err )
359+ os .Exit (1 )
360+ }
343361
344362 for _ , m := range msg [1 :] {
345- tbl .Append ([]string {
363+ if err := tbl .Append ([]string {
346364 gray .Sprint (getMultilineConditionPrefix (childPrefix )),
347365 "" ,
348366 "" ,
@@ -351,7 +369,10 @@ func addOtherConditions(prefix string, tbl *tablewriter.Table, objectTree *tree.
351369 "" ,
352370 "" ,
353371 "" ,
354- m })
372+ m }); err != nil {
373+ fmt .Printf ("Error appending row: %v" , err )
374+ os .Exit (1 )
375+ }
355376 }
356377 }
357378}
@@ -373,13 +394,16 @@ func addOtherConditionsV1Beta1(prefix string, tbl *tablewriter.Table, objectTree
373394 otherCondition := otherConditions [i ]
374395 otherDescriptor := newV1Beta1ConditionDescriptor (otherCondition )
375396 otherConditionPrefix := getChildPrefix (prefix + childrenPipe + filler , i , len (otherConditions ))
376- tbl .Append ([]string {
397+ if err := tbl .Append ([]string {
377398 fmt .Sprintf ("%s%s" , gray .Sprint (otherConditionPrefix ), cyan .Sprint (otherCondition .Type )),
378399 otherDescriptor .readyColor .Sprint (otherDescriptor .status ),
379400 otherDescriptor .readyColor .Sprint (otherDescriptor .severity ),
380401 otherDescriptor .readyColor .Sprint (otherDescriptor .reason ),
381402 otherDescriptor .age ,
382- otherDescriptor .message })
403+ otherDescriptor .message }); err != nil {
404+ fmt .Printf ("Error appending row: %v" , err )
405+ os .Exit (1 )
406+ }
383407 }
384408}
385409
0 commit comments