@@ -28,6 +28,7 @@ import (
28
28
"github.com/fatih/color"
29
29
"github.com/gobuffalo/flect"
30
30
"github.com/olekukonko/tablewriter"
31
+ "github.com/olekukonko/tablewriter/tw"
31
32
corev1 "k8s.io/api/core/v1"
32
33
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
33
34
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
66
67
func PrintObjectTree (tree * tree.ObjectTree , w io.Writer ) {
67
68
// Creates the output table
68
69
tbl := tablewriter .NewWriter (w )
69
- tbl .SetHeader ([]string {"NAME" , "REPLICAS" , "AVAILABLE" , "READY" , "UP TO DATE" , "STATUS" , "REASON" , "SINCE" , "MESSAGE" })
70
+ tbl .Header ([]string {"NAME" , "REPLICAS" , "AVAILABLE" , "READY" , "UP TO DATE" , "STATUS" , "REASON" , "SINCE" , "MESSAGE" })
70
71
71
72
formatTableTree (tbl )
72
73
// Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
@@ -81,7 +82,7 @@ func PrintObjectTree(tree *tree.ObjectTree, w io.Writer) {
81
82
func PrintObjectTreeV1Beta1 (tree * tree.ObjectTree ) {
82
83
// Creates the output table
83
84
tbl := tablewriter .NewWriter (os .Stdout )
84
- tbl .SetHeader ([]string {"NAME" , "READY" , "SEVERITY" , "REASON" , "SINCE" , "MESSAGE" })
85
+ tbl .Header ([]string {"NAME" , "READY" , "SEVERITY" , "REASON" , "SINCE" , "MESSAGE" })
85
86
86
87
formatTableTreeV1Beta1 (tbl )
87
88
// Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
@@ -93,32 +94,30 @@ func PrintObjectTreeV1Beta1(tree *tree.ObjectTree) {
93
94
94
95
// formats the table with required attributes.
95
96
func formatTableTree (tbl * tablewriter.Table ) {
96
- tbl .SetAutoWrapText ( false )
97
- tbl . SetHeaderAlignment ( tablewriter . ALIGN_LEFT )
98
- tbl . SetAlignment ( tablewriter . ALIGN_LEFT )
99
-
100
- tbl . SetCenterSeparator ( "" )
101
- tbl . SetRowSeparator ( "" )
102
-
103
- tbl . SetHeaderLine ( false )
104
- tbl . SetTablePadding ( " " )
105
- tbl . SetNoWhiteSpace ( true )
97
+ tbl .Options (
98
+ tablewriter . WithRowAutoWrap ( tw . WrapNone ),
99
+ tablewriter . WithHeaderAlignment ( tw . AlignLeft ),
100
+ tablewriter . WithRendition (tw. Rendition {
101
+ Borders : tw . BorderNone ,
102
+ Settings : tw. Settings {
103
+ Separators : tw . SeparatorsNone ,
104
+ }}),
105
+ tablewriter . WithPadding (tw. Padding { Right : " " }),
106
+ )
106
107
}
107
108
108
109
// formats the table with required attributes.
109
110
func formatTableTreeV1Beta1 (tbl * tablewriter.Table ) {
110
- tbl .SetAutoWrapText (false )
111
- tbl .SetHeaderAlignment (tablewriter .ALIGN_LEFT )
112
- tbl .SetAlignment (tablewriter .ALIGN_LEFT )
113
-
114
- tbl .SetCenterSeparator ("" )
115
- tbl .SetColumnSeparator ("" )
116
- tbl .SetRowSeparator ("" )
117
-
118
- tbl .SetHeaderLine (false )
119
- tbl .SetBorder (false )
120
- tbl .SetTablePadding (" " )
121
- tbl .SetNoWhiteSpace (true )
111
+ tbl .Options (
112
+ tablewriter .WithRowAutoWrap (tw .WrapNone ),
113
+ tablewriter .WithHeaderAlignment (tw .AlignLeft ),
114
+ tablewriter .WithRendition (tw.Rendition {
115
+ Borders : tw .BorderNone ,
116
+ Settings : tw.Settings {
117
+ Separators : tw .SeparatorsNone ,
118
+ }}),
119
+ tablewriter .WithPadding (tw.Padding {Right : " " }),
120
+ )
122
121
}
123
122
124
123
// addObjectRow add a row for a given object, and recursively for all the object's children.
0 commit comments