@@ -65,17 +65,15 @@ var (
65
65
// PrintObjectTree prints the cluster status to stdout.
66
66
// Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
67
67
func PrintObjectTree (tree * tree.ObjectTree , w io.Writer ) {
68
+
69
+ cfg := getObjectTreeConfig ()
68
70
// Creates the output table
69
- cfg := getTableTreeConfig ()
70
- tbl := tablewriter .NewTable (os .Stdin , tablewriter .WithConfig (cfg ), tablewriter .WithRendition (tw.Rendition { // Apply custom rendition
71
+ tbl := tablewriter .NewTable (os .Stdin , tablewriter .WithConfig (cfg ), tablewriter .WithRendition (tw.Rendition {
71
72
Settings : tw.Settings {
72
73
Separators : tw .SeparatorsNone , Lines : tw .LinesNone ,
73
74
},
74
75
Borders : tw .BorderNone ,
75
- }),)
76
-
77
- // tbl.SetCenterSeparator("") - rendition - https://github.com/olekukonko/tablewriter/blob/e520aed3bd36fcbc5935d6c4f778c38627788d1d/tw/symbols.go#L885
78
- // tbl.SetRowSeparator("") - rendition - https://github.com/olekukonko/tablewriter/blob/e520aed3bd36fcbc5935d6c4f778c38627788d1d/tw/symbols.go#L885
76
+ }))
79
77
80
78
// tbl := tablewriter.NewWriter(w)
81
79
tbl .Header ([]string {"NAME" , "REPLICAS" , "AVAILABLE" , "READY" , "UP TO DATE" , "STATUS" , "REASON" , "SINCE" , "MESSAGE" })
@@ -89,62 +87,56 @@ func PrintObjectTree(tree *tree.ObjectTree, w io.Writer) {
89
87
// PrintObjectTreeV1Beta1 prints the cluster status to stdout.
90
88
// Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
91
89
func PrintObjectTreeV1Beta1 (tree * tree.ObjectTree ) {
90
+ cfg := getObjectTreeConfigV1Beta1 ()
91
+
92
92
// Creates the output table
93
- // tbl := tablewriter.NewWriter(os.Stdout)
94
- cfg := getTableTreeConfig ()
95
- tbl := tablewriter .NewTable (os .Stdin , tablewriter .WithConfig (cfg ), tablewriter .WithRendition (tw.Rendition { // Apply custom rendition
93
+ tbl := tablewriter .NewTable (os .Stdin , tablewriter .WithConfig (cfg ), tablewriter .WithRendition (tw.Rendition {
96
94
Settings : tw.Settings {
97
- Lines : tw.Lines { ShowHeaderLine : tw .Off } ,
95
+ Separators : tw .SeparatorsNone , Lines : tw .LinesNone ,
98
96
},
99
- Borders : tw.Border { Top : tw . Off , Bottom : tw . Off , Left : tw . Off , Right : tw . Off } ,
100
- }), )
97
+ Borders : tw .BorderNone ,
98
+ }))
101
99
tbl .Header ([]string {"NAME" , "READY" , "SEVERITY" , "REASON" , "SINCE" , "MESSAGE" })
102
100
103
- // tbl.SetRowSeparator("") // different - rendition - https://github.com/olekukonko/tablewriter/blob/e520aed3bd36fcbc5935d6c4f778c38627788d1d/tw/symbols.go#L885
104
-
105
- // tbl.SetBorder(false) // different - rendition
106
-
107
- // formatTableTreeV1Beta1(tbl)
108
101
// Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
109
102
addObjectRowV1Beta1 ("" , tbl , tree , tree .GetRoot ())
110
103
111
104
// Prints the output table
112
105
tbl .Render ()
113
106
}
114
107
115
- // formats the table with required attributes .
116
- func getTableTreeConfig () ( tablewriter.Config ) {
108
+ // Creates custom configuration for the table for the object tree .
109
+ func getObjectTreeConfig () tablewriter.Config {
117
110
cfg := tablewriter.Config {
118
111
Row : tw.CellConfig {
119
112
Formatting : tw.CellFormatting {AutoWrap : tw .WrapNone },
120
- Alignment : tw.CellAlignment {Global : tw .AlignLeft },
121
- Padding : tw.CellPadding {Global : tw.Padding {Left : " " , Right : " " }},
113
+ Alignment : tw.CellAlignment {Global : tw .AlignLeft },
114
+ Padding : tw.CellPadding {Global : tw.Padding {Left : "" , Right : " " }},
122
115
},
123
116
Header : tw.CellConfig {
124
117
Alignment : tw.CellAlignment {Global : tw .AlignLeft },
125
118
},
126
- Behavior : tw.Behavior {TrimSpace : tw .On },
119
+ Behavior : tw.Behavior {TrimSpace : tw .Off },
127
120
}
128
121
129
122
return cfg
130
123
}
131
124
132
- // // formats the table with required attributes.
133
- // func formatTableTreeV1Beta1(tbl *tablewriter.Table) {
134
- // // tbl.SetAutoWrapText(false)
135
- // // tbl.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
136
- // // tbl.SetAlignment(tablewriter.ALIGN_LEFT)
137
-
138
- // // tbl.SetCenterSeparator("")
139
- // // tbl.SetColumnSeparator("")
140
- // // tbl.SetRowSeparator("") // different - rendition
141
-
142
- // // tbl.SetHeaderLine(false)
143
- // // tbl.SetBorder(false) // different - rendition
144
- // // tbl.SetTablePadding(" ")
145
- // // tbl.SetNoWhiteSpace(true)
146
- // }
125
+ func getObjectTreeConfigV1Beta1 () tablewriter.Config {
126
+ cfg := tablewriter.Config {
127
+ Row : tw.CellConfig {
128
+ Formatting : tw.CellFormatting {AutoWrap : tw .WrapNone },
129
+ Alignment : tw.CellAlignment {Global : tw .AlignLeft },
130
+ Padding : tw.CellPadding {Global : tw.Padding {Left : "" , Right : " " }},
131
+ },
132
+ Header : tw.CellConfig {
133
+ Alignment : tw.CellAlignment {Global : tw .AlignLeft },
134
+ },
135
+ Behavior : tw.Behavior {TrimSpace : tw .Off },
136
+ }
147
137
138
+ return cfg
139
+ }
148
140
// addObjectRow add a row for a given object, and recursively for all the object's children.
149
141
// NOTE: each row name gets a prefix, that generates a tree view like representation.
150
142
func addObjectRow (prefix string , tbl * tablewriter.Table , objectTree * tree.ObjectTree , obj ctrlclient.Object ) {
0 commit comments