@@ -65,17 +65,15 @@ var (
6565// PrintObjectTree prints the cluster status to stdout.
6666// Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
6767func PrintObjectTree (tree * tree.ObjectTree , w io.Writer ) {
68+
69+ cfg := getObjectTreeConfig ()
6870 // 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 {
7172 Settings : tw.Settings {
7273 Separators : tw .SeparatorsNone , Lines : tw .LinesNone ,
7374 },
7475 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+ }))
7977
8078 // tbl := tablewriter.NewWriter(w)
8179 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) {
8987// PrintObjectTreeV1Beta1 prints the cluster status to stdout.
9088// Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
9189func PrintObjectTreeV1Beta1 (tree * tree.ObjectTree ) {
90+ cfg := getObjectTreeConfigV1Beta1 ()
91+
9292 // 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 {
9694 Settings : tw.Settings {
97- Lines : tw.Lines { ShowHeaderLine : tw .Off } ,
95+ Separators : tw .SeparatorsNone , Lines : tw .LinesNone ,
9896 },
99- Borders : tw.Border { Top : tw . Off , Bottom : tw . Off , Left : tw . Off , Right : tw . Off } ,
100- }), )
97+ Borders : tw .BorderNone ,
98+ }))
10199 tbl .Header ([]string {"NAME" , "READY" , "SEVERITY" , "REASON" , "SINCE" , "MESSAGE" })
102100
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)
108101 // Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
109102 addObjectRowV1Beta1 ("" , tbl , tree , tree .GetRoot ())
110103
111104 // Prints the output table
112105 tbl .Render ()
113106}
114107
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 {
117110 cfg := tablewriter.Config {
118111 Row : tw.CellConfig {
119112 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 : " " }},
122115 },
123116 Header : tw.CellConfig {
124117 Alignment : tw.CellAlignment {Global : tw .AlignLeft },
125118 },
126- Behavior : tw.Behavior {TrimSpace : tw .On },
119+ Behavior : tw.Behavior {TrimSpace : tw .Off },
127120 }
128121
129122 return cfg
130123}
131124
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+ }
147137
138+ return cfg
139+ }
148140// addObjectRow add a row for a given object, and recursively for all the object's children.
149141// NOTE: each row name gets a prefix, that generates a tree view like representation.
150142func addObjectRow (prefix string , tbl * tablewriter.Table , objectTree * tree.ObjectTree , obj ctrlclient.Object ) {
0 commit comments