62
62
cyan = color .New (color .FgCyan )
63
63
)
64
64
65
- // PrintObjectTree prints the cluster status to stdout.
66
- // Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
67
- func PrintObjectTree (tree * tree.ObjectTree , w io.Writer ) {
68
- cfg := getObjectTreeConfig ()
69
- // Creates the output table
70
- tbl := tablewriter .NewTable (os .Stdin , tablewriter .WithConfig (cfg ), tablewriter .WithRendition (tw.Rendition {
71
- Settings : tw.Settings {
72
- Separators : tw .SeparatorsNone , Lines : tw .LinesNone ,
73
- },
74
- Borders : tw .BorderNone ,
75
- }))
76
-
77
- // tbl := tablewriter.NewWriter(w)
78
- tbl .Header ([]string {"NAME" , "REPLICAS" , "AVAILABLE" , "READY" , "UP TO DATE" , "STATUS" , "REASON" , "SINCE" , "MESSAGE" })
79
-
80
- addObjectRow ("" , tbl , tree , tree .GetRoot ())
81
-
82
- // Prints the output table
83
- tbl .Render ()
84
- }
85
-
86
- // PrintObjectTreeV1Beta1 prints the cluster status to stdout.
87
- // Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
88
- func PrintObjectTreeV1Beta1 (tree * tree.ObjectTree ) {
89
- cfg := getObjectTreeConfigV1Beta1 ()
90
-
91
- // Creates the output table
92
- tbl := tablewriter .NewTable (os .Stdin , tablewriter .WithConfig (cfg ), tablewriter .WithRendition (tw.Rendition {
93
- Settings : tw.Settings {
94
- Separators : tw .SeparatorsNone , Lines : tw .LinesNone ,
95
- },
96
- Borders : tw .BorderNone ,
97
- }))
98
- tbl .Header ([]string {"NAME" , "READY" , "SEVERITY" , "REASON" , "SINCE" , "MESSAGE" })
99
-
100
- // Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
101
- addObjectRowV1Beta1 ("" , tbl , tree , tree .GetRoot ())
102
-
103
- // Prints the output table
104
- tbl .Render ()
105
- }
106
-
107
- // Creates custom configuration for the table for the object tree.
108
- func getObjectTreeConfig () tablewriter.Config {
65
+ // CreateObjectTree creates a new tablewriter.Table for the object tree.
66
+ // Returns a new tablewriter.Table for the object tree.
67
+ func CreateObjectTree (w io.Writer ) * tablewriter.Table {
109
68
cfg := tablewriter.Config {
110
69
Row : tw.CellConfig {
111
70
Formatting : tw.CellFormatting {AutoWrap : tw .WrapNone },
@@ -118,10 +77,20 @@ func getObjectTreeConfig() tablewriter.Config {
118
77
Behavior : tw.Behavior {TrimSpace : tw .Off },
119
78
}
120
79
121
- return cfg
80
+ // Creates the output table
81
+ tbl := tablewriter .NewTable (w , tablewriter .WithConfig (cfg ), tablewriter .WithRendition (tw.Rendition {
82
+ Settings : tw.Settings {
83
+ Separators : tw .SeparatorsNone , Lines : tw .LinesNone ,
84
+ },
85
+ Borders : tw .BorderNone ,
86
+ }))
87
+
88
+ return tbl
122
89
}
123
90
124
- func getObjectTreeConfigV1Beta1 () tablewriter.Config {
91
+ // CreateObjectTreeV1Beta1 creates a new tablewriter.Table for the object tree.
92
+ // Returns a new tablewriter.Table for the object tree.
93
+ func CreateObjectTreeV1Beta1 (w io.Writer ) * tablewriter.Table {
125
94
cfg := tablewriter.Config {
126
95
Row : tw.CellConfig {
127
96
Formatting : tw.CellFormatting {AutoWrap : tw .WrapNone },
@@ -133,8 +102,41 @@ func getObjectTreeConfigV1Beta1() tablewriter.Config {
133
102
},
134
103
Behavior : tw.Behavior {TrimSpace : tw .Off },
135
104
}
105
+ // Creates the output table
106
+ tbl := tablewriter .NewTable (w , tablewriter .WithConfig (cfg ), tablewriter .WithRendition (tw.Rendition {
107
+ Settings : tw.Settings {
108
+ Separators : tw .SeparatorsNone , Lines : tw .LinesNone ,
109
+ },
110
+ Borders : tw .BorderNone ,
111
+ }))
112
+
113
+ return tbl
114
+ }
115
+
116
+ // PrintObjectTree prints the cluster status to stdout.
117
+ // Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
118
+ func PrintObjectTree (tree * tree.ObjectTree , w io.Writer ) {
119
+ tbl := CreateObjectTree (w )
136
120
137
- return cfg
121
+ tbl .Header ([]string {"NAME" , "REPLICAS" , "AVAILABLE" , "READY" , "UP TO DATE" , "STATUS" , "REASON" , "SINCE" , "MESSAGE" })
122
+
123
+ addObjectRow ("" , tbl , tree , tree .GetRoot ())
124
+
125
+ // Prints the output table
126
+ tbl .Render ()
127
+ }
128
+
129
+ // PrintObjectTreeV1Beta1 prints the cluster status to stdout.
130
+ // Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
131
+ func PrintObjectTreeV1Beta1 (tree * tree.ObjectTree ) {
132
+ tbl := CreateObjectTreeV1Beta1 (os .Stdin )
133
+ tbl .Header ([]string {"NAME" , "READY" , "SEVERITY" , "REASON" , "SINCE" , "MESSAGE" })
134
+
135
+ // Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
136
+ addObjectRowV1Beta1 ("" , tbl , tree , tree .GetRoot ())
137
+
138
+ // Prints the output table
139
+ tbl .Render ()
138
140
}
139
141
140
142
// addObjectRow add a row for a given object, and recursively for all the object's children.
0 commit comments