Skip to content

Commit 54cab07

Browse files
committed
Bumping tablewriter to v1.0.9 - latest
1 parent 0db4bf4 commit 54cab07

File tree

8 files changed

+118
-80
lines changed

8 files changed

+118
-80
lines changed

go.mod

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/google/cel-go v0.26.0
2222
github.com/google/go-cmp v0.7.0
2323
github.com/google/go-github/v53 v53.2.0
24-
github.com/olekukonko/tablewriter v0.0.5
24+
github.com/olekukonko/tablewriter v1.0.9
2525
github.com/onsi/ginkgo/v2 v2.25.3
2626
github.com/onsi/gomega v1.38.2
2727
github.com/pkg/errors v0.9.1
@@ -99,23 +99,26 @@ require (
9999
github.com/json-iterator/go v1.1.12 // indirect
100100
github.com/kylelemons/godebug v1.1.0 // indirect
101101
github.com/mailru/easyjson v0.7.7 // indirect
102-
github.com/mattn/go-colorable v0.1.13 // indirect
102+
github.com/mattn/go-colorable v0.1.14 // indirect
103103
github.com/mattn/go-isatty v0.0.20 // indirect
104-
github.com/mattn/go-runewidth v0.0.14 // indirect
104+
github.com/mattn/go-runewidth v0.0.16 // indirect
105105
github.com/mitchellh/copystructure v1.2.0 // indirect
106106
github.com/mitchellh/reflectwalk v1.0.2 // indirect
107107
github.com/moby/spdystream v0.5.0 // indirect
108108
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
109109
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
110110
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
111111
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
112+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
113+
github.com/olekukonko/errors v1.1.0 // indirect
114+
github.com/olekukonko/ll v0.1.1 // indirect
112115
github.com/opencontainers/go-digest v1.0.0 // indirect
113116
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
114117
github.com/pmezard/go-difflib v1.0.0 // indirect
115118
github.com/prometheus/client_model v0.6.1 // indirect
116119
github.com/prometheus/common v0.62.0 // indirect
117120
github.com/prometheus/procfs v0.15.1 // indirect
118-
github.com/rivo/uniseg v0.4.2 // indirect
121+
github.com/rivo/uniseg v0.4.7 // indirect
119122
github.com/sagikazarmark/locafero v0.11.0 // indirect
120123
github.com/shopspring/decimal v1.4.0 // indirect
121124
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect

go.sum

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,12 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
223223
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
224224
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
225225
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
226-
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
227-
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
228-
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
226+
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
227+
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
229228
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
230229
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
231-
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
232-
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
233-
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
230+
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
231+
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
234232
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
235233
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
236234
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
@@ -247,8 +245,14 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
247245
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
248246
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
249247
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
250-
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
251-
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
248+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc=
249+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0=
250+
github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM=
251+
github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
252+
github.com/olekukonko/ll v0.1.1 h1:9Dfeed5/Mgaxb9lHRAftLK9pVfYETvHn+If6lywVhJc=
253+
github.com/olekukonko/ll v0.1.1/go.mod h1:2dJo+hYZcJMLMbKwHEWvxCUbAOLc/CXWS9noET22Mdo=
254+
github.com/olekukonko/tablewriter v1.0.9 h1:XGwRsYLC2bY7bNd93Dk51bcPZksWZmLYuaTHR0FqfL8=
255+
github.com/olekukonko/tablewriter v1.0.9/go.mod h1:5c+EBPeSqvXnLLgkm9isDdzR3wjfBkHR9Nhfp3NWrzo=
252256
github.com/onsi/ginkgo/v2 v2.25.3 h1:Ty8+Yi/ayDAGtk4XxmmfUy4GabvM+MegeB4cDLRi6nw=
253257
github.com/onsi/ginkgo/v2 v2.25.3/go.mod h1:43uiyQC4Ed2tkOzLsEYm7hnrb7UJTWHYNsuy3bG/snE=
254258
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
@@ -275,8 +279,8 @@ github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkq
275279
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
276280
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
277281
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
278-
github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8=
279-
github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
282+
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
283+
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
280284
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
281285
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
282286
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
@@ -466,7 +470,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
466470
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
467471
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
468472
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
469-
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
470473
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
471474
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
472475
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=

hack/tools/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ require (
120120
github.com/json-iterator/go v1.1.12 // indirect
121121
github.com/kevinburke/ssh_config v1.2.0 // indirect
122122
github.com/mailru/easyjson v0.7.7 // indirect
123-
github.com/mattn/go-colorable v0.1.13 // indirect
123+
github.com/mattn/go-colorable v0.1.14 // indirect
124124
github.com/mattn/go-isatty v0.0.20 // indirect
125-
github.com/mattn/go-runewidth v0.0.15 // indirect
125+
github.com/mattn/go-runewidth v0.0.16 // indirect
126126
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
127127
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
128128
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
@@ -135,7 +135,7 @@ require (
135135
github.com/prometheus/client_model v0.6.1 // indirect
136136
github.com/prometheus/common v0.62.0 // indirect
137137
github.com/prometheus/procfs v0.15.1 // indirect
138-
github.com/rivo/uniseg v0.4.4 // indirect
138+
github.com/rivo/uniseg v0.4.7 // indirect
139139
github.com/sagikazarmark/locafero v0.11.0 // indirect
140140
github.com/saschagrunert/go-modiff v1.3.5 // indirect
141141
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect

hack/tools/go.sum

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,12 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
231231
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
232232
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
233233
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
234-
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
235-
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
236-
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
234+
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
235+
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
237236
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
238237
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
239-
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
240-
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
238+
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
239+
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
241240
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
242241
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
243242
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
@@ -294,8 +293,8 @@ github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkq
294293
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
295294
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
296295
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
297-
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
298-
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
296+
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
297+
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
299298
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
300299
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
301300
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
@@ -443,7 +442,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
443442
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
444443
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
445444
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
446-
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
447445
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
448446
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
449447
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

internal/util/tree/tree.go

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/fatih/color"
2929
"github.com/gobuffalo/flect"
3030
"github.com/olekukonko/tablewriter"
31+
"github.com/olekukonko/tablewriter/tw"
3132
corev1 "k8s.io/api/core/v1"
3233
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3334
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -64,12 +65,19 @@ var (
6465
// PrintObjectTree prints the cluster status to stdout.
6566
// Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
6667
func PrintObjectTree(tree *tree.ObjectTree, w io.Writer) {
68+
69+
cfg := getObjectTreeConfig()
6770
// Creates the output table
68-
tbl := tablewriter.NewWriter(w)
69-
tbl.SetHeader([]string{"NAME", "REPLICAS", "AVAILABLE", "READY", "UP TO DATE", "STATUS", "REASON", "SINCE", "MESSAGE"})
71+
tbl := tablewriter.NewTable(os.Stdin, tablewriter.WithConfig(cfg), tablewriter.WithRendition(tw.Rendition{
72+
Settings: tw.Settings{
73+
Separators: tw.SeparatorsNone, Lines: tw.LinesNone,
74+
},
75+
Borders: tw.BorderNone,
76+
}))
77+
78+
// tbl := tablewriter.NewWriter(w)
79+
tbl.Header([]string{"NAME", "REPLICAS", "AVAILABLE", "READY", "UP TO DATE", "STATUS", "REASON", "SINCE", "MESSAGE"})
7080

71-
formatTableTree(tbl)
72-
// Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
7381
addObjectRow("", tbl, tree, tree.GetRoot())
7482

7583
// Prints the output table
@@ -79,48 +87,56 @@ func PrintObjectTree(tree *tree.ObjectTree, w io.Writer) {
7987
// PrintObjectTreeV1Beta1 prints the cluster status to stdout.
8088
// Note: this function is exposed only for usage in clusterctl and Cluster API E2E tests.
8189
func PrintObjectTreeV1Beta1(tree *tree.ObjectTree) {
90+
cfg := getObjectTreeConfigV1Beta1()
91+
8292
// Creates the output table
83-
tbl := tablewriter.NewWriter(os.Stdout)
84-
tbl.SetHeader([]string{"NAME", "READY", "SEVERITY", "REASON", "SINCE", "MESSAGE"})
93+
tbl := tablewriter.NewTable(os.Stdin, tablewriter.WithConfig(cfg), tablewriter.WithRendition(tw.Rendition{
94+
Settings: tw.Settings{
95+
Separators: tw.SeparatorsNone, Lines: tw.LinesNone,
96+
},
97+
Borders: tw.BorderNone,
98+
}))
99+
tbl.Header([]string{"NAME", "READY", "SEVERITY", "REASON", "SINCE", "MESSAGE"})
85100

86-
formatTableTreeV1Beta1(tbl)
87101
// Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
88102
addObjectRowV1Beta1("", tbl, tree, tree.GetRoot())
89103

90104
// Prints the output table
91105
tbl.Render()
92106
}
93107

94-
// formats the table with required attributes.
95-
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)
108+
// Creates custom configuration for the table for the object tree.
109+
func getObjectTreeConfig() tablewriter.Config {
110+
cfg := tablewriter.Config{
111+
Row: tw.CellConfig{
112+
Formatting: tw.CellFormatting{AutoWrap: tw.WrapNone},
113+
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
114+
Padding: tw.CellPadding{Global: tw.Padding{Left: "", Right: " "}},
115+
},
116+
Header: tw.CellConfig{
117+
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
118+
},
119+
Behavior: tw.Behavior{TrimSpace: tw.Off},
120+
}
121+
122+
return cfg
106123
}
107124

108-
// formats the table with required attributes.
109-
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("")
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+
}
117137

118-
tbl.SetHeaderLine(false)
119-
tbl.SetBorder(false)
120-
tbl.SetTablePadding(" ")
121-
tbl.SetNoWhiteSpace(true)
138+
return cfg
122139
}
123-
124140
// addObjectRow add a row for a given object, and recursively for all the object's children.
125141
// NOTE: each row name gets a prefix, that generates a tree view like representation.
126142
func addObjectRow(prefix string, tbl *tablewriter.Table, objectTree *tree.ObjectTree, obj ctrlclient.Object) {

internal/util/tree/tree_test.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/fatih/color"
2626
"github.com/olekukonko/tablewriter"
27+
"github.com/olekukonko/tablewriter/tw"
2728
. "github.com/onsi/gomega"
2829
gtype "github.com/onsi/gomega/types"
2930
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -280,10 +281,15 @@ func Test_V1Beta1TreePrefix(t *testing.T) {
280281
g := NewWithT(t)
281282
var output bytes.Buffer
282283

283-
// Creates the output table
284-
tbl := tablewriter.NewWriter(&output)
284+
cfg := getObjectTreeConfigV1Beta1()
285285

286-
formatTableTreeV1Beta1(tbl)
286+
// Creates the output table
287+
tbl := tablewriter.NewTable(&output, tablewriter.WithConfig(cfg), tablewriter.WithRendition(tw.Rendition{
288+
Settings: tw.Settings{
289+
Separators: tw.SeparatorsNone, Lines: tw.LinesNone,
290+
},
291+
Borders: tw.BorderNone,
292+
}))
287293

288294
// Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
289295
addObjectRowV1Beta1("", tbl, tt.objectTree, tt.objectTree.GetRoot())
@@ -511,10 +517,16 @@ func Test_TreePrefix(t *testing.T) {
511517
g := NewWithT(t)
512518
var output bytes.Buffer
513519

520+
cfg := getObjectTreeConfig()
514521
// Creates the output table
515-
tbl := tablewriter.NewWriter(&output)
516-
517-
formatTableTree(tbl)
522+
tbl := tablewriter.NewTable(&output, tablewriter.WithConfig(cfg), tablewriter.WithRendition(tw.Rendition{
523+
Settings: tw.Settings{
524+
Separators: tw.SeparatorsNone, Lines: tw.LinesNone,
525+
},
526+
Borders: tw.BorderNone,
527+
}))
528+
529+
// tbl := tablewriter.NewWriter(w)
518530

519531
// Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status.
520532
addObjectRow("", tbl, tt.objectTree, tt.objectTree.GetRoot())

test/go.mod

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ require (
9797
github.com/json-iterator/go v1.1.12 // indirect
9898
github.com/kylelemons/godebug v1.1.0 // indirect
9999
github.com/mailru/easyjson v0.7.7 // indirect
100-
github.com/mattn/go-colorable v0.1.13 // indirect
100+
github.com/mattn/go-colorable v0.1.14 // indirect
101101
github.com/mattn/go-isatty v0.0.20 // indirect
102-
github.com/mattn/go-runewidth v0.0.14 // indirect
102+
github.com/mattn/go-runewidth v0.0.16 // indirect
103103
github.com/mitchellh/copystructure v1.2.0 // indirect
104104
github.com/mitchellh/reflectwalk v1.0.2 // indirect
105105
github.com/moby/docker-image-spec v1.3.1 // indirect
@@ -110,15 +110,18 @@ require (
110110
github.com/morikuni/aec v1.0.0 // indirect
111111
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
112112
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
113-
github.com/olekukonko/tablewriter v0.0.5 // indirect
113+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
114+
github.com/olekukonko/errors v1.1.0 // indirect
115+
github.com/olekukonko/ll v0.1.1 // indirect
116+
github.com/olekukonko/tablewriter v1.0.9 // indirect
114117
github.com/opencontainers/go-digest v1.0.0 // indirect
115118
github.com/opencontainers/image-spec v1.0.2 // indirect
116119
github.com/pelletier/go-toml v1.9.5 // indirect
117120
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
118121
github.com/pmezard/go-difflib v1.0.0 // indirect
119122
github.com/prometheus/client_model v0.6.1 // indirect
120123
github.com/prometheus/procfs v0.15.1 // indirect
121-
github.com/rivo/uniseg v0.4.2 // indirect
124+
github.com/rivo/uniseg v0.4.7 // indirect
122125
github.com/sagikazarmark/locafero v0.11.0 // indirect
123126
github.com/shopspring/decimal v1.4.0 // indirect
124127
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect

0 commit comments

Comments
 (0)