Skip to content

Commit 52401e3

Browse files
authored
Update tablewriter (#1212)
* Bump tablewriter to the latest version * Run go vendor * Fix compile issue after tablewriter update * Fix tests after tablewriter upgrade
1 parent 833c88b commit 52401e3

File tree

158 files changed

+39675
-18039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+39675
-18039
lines changed

functional-tests/functional_tests.go

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -584,24 +584,54 @@ func TableToSliceMapStringString(table string) map[string]map[string]string {
584584
results := map[string]map[string]string{}
585585

586586
tableRows := strings.Split(table, "\n")
587-
headings := []string{}
587+
var headings []string
588588

589-
for _, heading := range strings.Split(tableRows[1], "|") {
589+
if len(tableRows) < 2 {
590+
return results
591+
}
592+
593+
594+
// Find the header row. It's usually the first row containing '│'
595+
headerRowIndex := -1
596+
for i, row := range tableRows {
597+
if strings.Contains(row, "│") {
598+
headerRowIndex = i
599+
break
600+
}
601+
}
602+
603+
if headerRowIndex == -1 {
604+
return results
605+
}
606+
607+
// Split by any of the box drawing vertical bars or the old pipe
608+
splitFn := func(c rune) bool {
609+
return c == '│' || c == '|'
610+
}
611+
612+
for _, heading := range strings.FieldsFunc(tableRows[headerRowIndex], splitFn) {
590613
headings = append(headings, strings.TrimSpace(heading))
591614
}
592615

593-
for _, row := range tableRows[2:] {
594-
if !strings.Contains(row, "-+-") {
595-
rowValues := strings.Split(row, "|")
616+
for _, row := range tableRows[headerRowIndex+1:] {
617+
// Skip separator rows (they contain horizontal box drawing characters)
618+
if strings.ContainsAny(row, "─┬┐├┼┤└┴┘") || strings.Contains(row, "-+-") {
619+
continue
620+
}
621+
622+
if strings.Contains(row, "│") || strings.Contains(row, "|") {
623+
rowValues := strings.FieldsFunc(row, splitFn)
596624

597625
result := map[string]string{}
598626
for i, value := range rowValues {
599-
if value != "" {
627+
if i < len(headings) {
600628
result[headings[i]] = strings.TrimSpace(value)
601629
}
602630
}
603631

604-
results[result["TARGET NAME"]] = result
632+
if targetName, ok := result["TARGET NAME"]; ok {
633+
results[targetName] = result
634+
}
605635
}
606636
}
607637

functional-tests/hoverctl/status_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,40 @@ var _ = Describe("when I use hoverctl status", func() {
2929

3030
It("Print it", func() {
3131
output := functional_tests.Run(hoverctlBinary, "status")
32-
Expect(output).To(ContainSubstring("Hoverfly | running"))
33-
Expect(output).To(ContainSubstring("Admin port | " + hoverfly.GetAdminPort()))
34-
Expect(output).To(ContainSubstring("Proxy port | 8500"))
35-
Expect(output).To(ContainSubstring("Proxy type | forward"))
36-
Expect(output).To(ContainSubstring("Mode | simulate"))
37-
Expect(output).To(ContainSubstring("Middleware | disabled"))
38-
Expect(output).To(ContainSubstring("CORS | disabled"))
32+
Expect(output).To(ContainSubstring("Hoverfly running"))
33+
Expect(output).To(ContainSubstring("Admin port " + hoverfly.GetAdminPort()))
34+
Expect(output).To(ContainSubstring("Proxy port 8500"))
35+
Expect(output).To(ContainSubstring("Proxy type forward"))
36+
Expect(output).To(ContainSubstring("Mode simulate"))
37+
Expect(output).To(ContainSubstring("Middleware disabled"))
38+
Expect(output).To(ContainSubstring("CORS disabled"))
3939
})
4040

4141
It("should get the mode from Hoverfly", func() {
4242
hoverfly.SetMode("capture")
4343

4444
output := functional_tests.Run(hoverctlBinary, "status")
45-
Expect(output).To(ContainSubstring("Mode | capture"))
45+
Expect(output).To(ContainSubstring("Mode capture"))
4646

4747
hoverfly.SetMode("synthesize")
4848

4949
output = functional_tests.Run(hoverctlBinary, "status")
50-
Expect(output).To(ContainSubstring("Mode | synthesize"))
50+
Expect(output).To(ContainSubstring("Mode synthesize"))
5151

5252
hoverfly.SetMode("modify")
5353

5454
output = functional_tests.Run(hoverctlBinary, "status")
55-
Expect(output).To(ContainSubstring("Mode | modify"))
55+
Expect(output).To(ContainSubstring("Mode modify"))
5656
})
5757

5858
It("should get the middleware from Hoverfly", func() {
5959
output := functional_tests.Run(hoverctlBinary, "status")
60-
Expect(output).To(ContainSubstring("Middleware | disabled"))
60+
Expect(output).To(ContainSubstring("Middleware disabled"))
6161

6262
hoverfly.SetMiddleware("python", functional_tests.Middleware)
6363

6464
output = functional_tests.Run(hoverctlBinary, "status")
65-
Expect(output).To(ContainSubstring("Middleware | enabled"))
65+
Expect(output).To(ContainSubstring("Middleware enabled"))
6666

6767
Expect(output).To(ContainSubstring("Hoverfly is using local middleware with the command python and the script:"))
6868
Expect(output).To(ContainSubstring(functional_tests.Middleware))
@@ -88,7 +88,7 @@ var _ = Describe("when I use hoverctl status", func() {
8888

8989
It("should get proxy type from Hoverfly", func() {
9090
output := functional_tests.Run(hoverctlBinary, "status")
91-
Expect(output).To(ContainSubstring("Proxy type | reverse (webserver)"))
91+
Expect(output).To(ContainSubstring("Proxy type reverse (webserver)"))
9292
})
9393
})
9494
})
@@ -110,7 +110,7 @@ var _ = Describe("when I use hoverctl status", func() {
110110

111111
It("should get the CORS status from Hoverfly", func() {
112112
output := functional_tests.Run(hoverctlBinary, "status")
113-
Expect(output).To(ContainSubstring("CORS | enabled"))
113+
Expect(output).To(ContainSubstring("CORS enabled"))
114114
})
115115
})
116116
})

go.mod

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/jackwakefield/gopac v1.0.3-0.20180823145755-c4d2e0b9a672
2626
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
2727
github.com/mitchellh/go-homedir v1.1.0
28-
github.com/olekukonko/tablewriter v0.0.5
28+
github.com/olekukonko/tablewriter v1.1.2
2929
github.com/onsi/ginkgo v1.16.5
3030
github.com/onsi/gomega v1.38.3
3131
github.com/pborman/uuid v1.2.1
@@ -48,7 +48,11 @@ require (
4848
require (
4949
github.com/BurntSushi/toml v1.5.0 // indirect
5050
github.com/aymerick/raymond v2.0.2+incompatible // indirect
51+
github.com/clipperhouse/displaywidth v0.6.0 // indirect
52+
github.com/clipperhouse/stringish v0.1.1 // indirect
53+
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
5154
github.com/corpix/uarand v0.2.0 // indirect
55+
github.com/fatih/color v1.15.0 // indirect
5256
github.com/fsnotify/fsnotify v1.9.0 // indirect
5357
github.com/gabriel-vasile/mimetype v1.4.11 // indirect
5458
github.com/go-playground/locales v0.14.1 // indirect
@@ -61,11 +65,15 @@ require (
6165
github.com/inconshreveable/mousetrap v1.1.0 // indirect
6266
github.com/leodido/go-urn v1.4.0 // indirect
6367
github.com/magiconair/properties v1.8.9 // indirect
64-
github.com/mattn/go-runewidth v0.0.16 // indirect
68+
github.com/mattn/go-colorable v0.1.13 // indirect
69+
github.com/mattn/go-isatty v0.0.19 // indirect
70+
github.com/mattn/go-runewidth v0.0.19 // indirect
6571
github.com/mitchellh/mapstructure v1.5.0 // indirect
6672
github.com/nxadm/tail v1.4.11 // indirect
73+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
74+
github.com/olekukonko/errors v1.1.0 // indirect
75+
github.com/olekukonko/ll v0.1.3 // indirect
6776
github.com/pkg/errors v0.9.1 // indirect
68-
github.com/rivo/uniseg v0.4.7 // indirect
6977
github.com/robertkrimen/otto v0.5.1 // indirect
7078
github.com/spf13/cast v1.7.1 // indirect
7179
github.com/spf13/jwalterweatherman v1.1.0 // indirect

go.sum

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
2525
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
2626
github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4=
2727
github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs=
28+
github.com/clipperhouse/displaywidth v0.6.0 h1:k32vueaksef9WIKCNcoqRNyKbyvkvkysNYnAWz2fN4s=
29+
github.com/clipperhouse/displaywidth v0.6.0/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o=
30+
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
31+
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
32+
github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4=
33+
github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
2834
github.com/codegangsta/negroni v1.0.0 h1:+aYywywx4bnKXWvoWtRfJ91vC59NbEhEY03sZjQhbVY=
2935
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
3036
github.com/corpix/uarand v0.2.0 h1:U98xXwud/AVuCpkpgfPF7J5TQgr7R5tqT8VZP5KWbzE=
@@ -38,6 +44,8 @@ github.com/dghubble/sling v1.4.2/go.mod h1:o0arCOz0HwfqYQJLrRtqunaWOn4X6jxE/6ORK
3844
github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
3945
github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
4046
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
47+
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
48+
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
4149
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
4250
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
4351
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
@@ -118,9 +126,13 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
118126
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
119127
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
120128
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
121-
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
122-
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
123-
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
129+
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
130+
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
131+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
132+
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
133+
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
134+
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
135+
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
124136
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
125137
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
126138
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -129,8 +141,14 @@ github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI
129141
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
130142
github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
131143
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
132-
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
133-
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
144+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc=
145+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0=
146+
github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM=
147+
github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
148+
github.com/olekukonko/ll v0.1.3 h1:sV2jrhQGq5B3W0nENUISCR6azIPf7UBUpVq0x/y70Fg=
149+
github.com/olekukonko/ll v0.1.3/go.mod h1:b52bVQRRPObe+yyBl0TxNfhesL0nedD4Cht0/zx55Ew=
150+
github.com/olekukonko/tablewriter v1.1.2 h1:L2kI1Y5tZBct/O/TyZK1zIE9GlBj/TVs+AY5tZDCDSc=
151+
github.com/olekukonko/tablewriter v1.1.2/go.mod h1:z7SYPugVqGVavWoA2sGsFIoOVNmEHxUAAMrhXONtfkg=
134152
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
135153
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
136154
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
@@ -153,9 +171,6 @@ github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
153171
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
154172
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg=
155173
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
156-
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
157-
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
158-
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
159174
github.com/robertkrimen/otto v0.5.1 h1:avDI4ToRk8k1hppLdYFTuuzND41n37vPGJU7547dGf0=
160175
github.com/robertkrimen/otto v0.5.1/go.mod h1:bS433I4Q9p+E5pZLu7r17vP6FkE6/wLxBdmKjoqJXF8=
161176
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
@@ -248,8 +263,10 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
248263
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
249264
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
250265
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
266+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
251267
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
252268
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
269+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
253270
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
254271
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
255272
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=

hoverctl/cmd/utils.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ func askForInput(value string, sensitive bool) string {
7575
func drawTable(data [][]string, header bool) {
7676
table := tablewriter.NewWriter(os.Stdout)
7777
if header {
78-
table.SetHeader(data[0])
78+
headerData := make([]any, len(data[0]))
79+
for i, v := range data[0] {
80+
headerData[i] = v
81+
}
82+
table.Header(headerData...)
7983
data = data[1:]
8084
}
8185

vendor/github.com/clipperhouse/displaywidth/.gitignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/clipperhouse/displaywidth/AGENTS.md

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/clipperhouse/displaywidth/CHANGELOG.md

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/rivo/uniseg/LICENSE.txt renamed to vendor/github.com/clipperhouse/displaywidth/LICENSE

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)