Skip to content

Commit 577fc84

Browse files
authored
refactor: replace github.com/olekukonko/tablewriter with text/tablewriter (#40158)
* refactor: replace github.com/olekukonko/tablewriter with text/tablewriter the downside is that there's no separator between headers and table content but that's a style issue. * lint: go mod tidy * test: use test output to write table
1 parent e15909d commit 577fc84

4 files changed

Lines changed: 32 additions & 129 deletions

File tree

NOTICE.txt

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -19821,35 +19821,6 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
1982119821

1982219822

1982319823

19824-
--------------------------------------------------------------------------------
19825-
Dependency : github.com/olekukonko/tablewriter
19826-
Version: v0.0.5
19827-
Licence type (autodetected): MIT
19828-
--------------------------------------------------------------------------------
19829-
19830-
Contents of probable licence file $GOMODCACHE/github.com/olekukonko/tablewriter@v0.0.5/LICENSE.md:
19831-
19832-
Copyright (C) 2014 by Oleku Konko
19833-
19834-
Permission is hereby granted, free of charge, to any person obtaining a copy
19835-
of this software and associated documentation files (the "Software"), to deal
19836-
in the Software without restriction, including without limitation the rights
19837-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19838-
copies of the Software, and to permit persons to whom the Software is
19839-
furnished to do so, subject to the following conditions:
19840-
19841-
The above copyright notice and this permission notice shall be included in
19842-
all copies or substantial portions of the Software.
19843-
19844-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19845-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19846-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19847-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19848-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19849-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19850-
THE SOFTWARE.
19851-
19852-
1985319824
--------------------------------------------------------------------------------
1985419825
Dependency : github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter
1985519826
Version: v0.132.0
@@ -55238,37 +55209,6 @@ The above copyright notice and this permission notice shall be included in all c
5523855209
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5523955210

5524055211

55241-
--------------------------------------------------------------------------------
55242-
Dependency : github.com/mattn/go-runewidth
55243-
Version: v0.0.16
55244-
Licence type (autodetected): MIT
55245-
--------------------------------------------------------------------------------
55246-
55247-
Contents of probable licence file $GOMODCACHE/github.com/mattn/go-runewidth@v0.0.16/LICENSE:
55248-
55249-
The MIT License (MIT)
55250-
55251-
Copyright (c) 2016 Yasuhiro Matsumoto
55252-
55253-
Permission is hereby granted, free of charge, to any person obtaining a copy
55254-
of this software and associated documentation files (the "Software"), to deal
55255-
in the Software without restriction, including without limitation the rights
55256-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
55257-
copies of the Software, and to permit persons to whom the Software is
55258-
furnished to do so, subject to the following conditions:
55259-
55260-
The above copyright notice and this permission notice shall be included in all
55261-
copies or substantial portions of the Software.
55262-
55263-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55264-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
55265-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55266-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55267-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55268-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55269-
SOFTWARE.
55270-
55271-
5527255212
--------------------------------------------------------------------------------
5527355213
Dependency : github.com/mdlayher/netlink
5527455214
Version: v1.7.2
@@ -61232,37 +61172,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6123261172
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6123361173

6123461174

61235-
--------------------------------------------------------------------------------
61236-
Dependency : github.com/rivo/uniseg
61237-
Version: v0.4.7
61238-
Licence type (autodetected): MIT
61239-
--------------------------------------------------------------------------------
61240-
61241-
Contents of probable licence file $GOMODCACHE/github.com/rivo/uniseg@v0.4.7/LICENSE.txt:
61242-
61243-
MIT License
61244-
61245-
Copyright (c) 2019 Oliver Kuederle
61246-
61247-
Permission is hereby granted, free of charge, to any person obtaining a copy
61248-
of this software and associated documentation files (the "Software"), to deal
61249-
in the Software without restriction, including without limitation the rights
61250-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
61251-
copies of the Software, and to permit persons to whom the Software is
61252-
furnished to do so, subject to the following conditions:
61253-
61254-
The above copyright notice and this permission notice shall be included in all
61255-
copies or substantial portions of the Software.
61256-
61257-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61258-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61259-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61260-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61261-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61262-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61263-
SOFTWARE.
61264-
61265-
6126661175
--------------------------------------------------------------------------------
6126761176
Dependency : github.com/rogpeppe/go-internal
6126861177
Version: v1.14.1

go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ require (
103103
github.com/mattn/go-colorable v0.1.13 // indirect
104104
github.com/miekg/dns v1.1.66
105105
github.com/mitchellh/gox v1.0.1
106-
github.com/olekukonko/tablewriter v0.0.5
107106
github.com/osquery/osquery-go v0.0.0-20231108163517-e3cde127e724
108107
github.com/pkg/errors v0.9.1
109108
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
@@ -378,7 +377,6 @@ require (
378377
github.com/mailru/easyjson v0.7.7 // indirect
379378
github.com/mattn/go-ieproxy v0.0.1 // indirect
380379
github.com/mattn/go-isatty v0.0.20 // indirect
381-
github.com/mattn/go-runewidth v0.0.16 // indirect
382380
github.com/mileusna/useragent v1.3.5 // indirect
383381
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
384382
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
@@ -408,7 +406,6 @@ require (
408406
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
409407
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
410408
github.com/prometheus/client_golang v1.22.0 // indirect
411-
github.com/rivo/uniseg v0.4.7 // indirect
412409
github.com/rogpeppe/go-internal v1.14.1 // indirect
413410
github.com/rs/cors v1.11.1 // indirect
414411
github.com/segmentio/fasthash v1.0.3 // indirect

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
761761
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
762762
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
763763
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
764-
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
765-
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
766-
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
767764
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
768765
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
769766
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
@@ -834,8 +831,6 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
834831
github.com/oklog/ulid/v2 v2.0.2/go.mod h1:mtBL0Qe/0HAx6/a4Z30qxVIAL1eQDweXq5lxOEiwQ68=
835832
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
836833
github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
837-
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
838-
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
839834
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
840835
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
841836
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
@@ -910,9 +905,6 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X
910905
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
911906
github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI=
912907
github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
913-
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
914-
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
915-
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
916908
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
917909
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
918910
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=

x-pack/filebeat/input/awss3/input_benchmark_test.go

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import (
1111
"os"
1212
"path/filepath"
1313
"runtime"
14+
"strings"
1415
"sync"
1516
"testing"
17+
"text/tabwriter"
1618
"time"
1719

1820
"github.com/stretchr/testify/assert"
@@ -25,7 +27,6 @@ import (
2527
s3Types "github.com/aws/aws-sdk-go-v2/service/s3/types"
2628
sqsTypes "github.com/aws/aws-sdk-go-v2/service/sqs/types"
2729
"github.com/dustin/go-humanize"
28-
"github.com/olekukonko/tablewriter"
2930

3031
conf "github.com/elastic/elastic-agent-libs/config"
3132
"github.com/elastic/elastic-agent-libs/logp"
@@ -281,11 +282,11 @@ func TestBenchmarkInputSQS(t *testing.T) {
281282
}
282283

283284
headers := []string{
284-
"Max Msgs Inflight",
285-
"Events per sec",
286-
"S3 Bytes per sec",
287-
"Time (sec)",
288-
"CPUs",
285+
"MAX MSGS INFLIGHT",
286+
"EVENTS PER SEC",
287+
"S3 BYTES PER SEC",
288+
"TIME (SEC)",
289+
"CPUS",
289290
}
290291
data := make([][]string, 0)
291292
for _, r := range results {
@@ -298,10 +299,12 @@ func TestBenchmarkInputSQS(t *testing.T) {
298299
})
299300
}
300301

301-
table := tablewriter.NewWriter(os.Stdout)
302-
table.SetHeader(headers)
303-
table.AppendBulk(data)
304-
table.Render()
302+
w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', tabwriter.Debug)
303+
fmt.Fprintln(w, strings.Join(headers, "\t"))
304+
for _, d := range data {
305+
fmt.Fprintln(w, strings.Join(d, "\t"))
306+
}
307+
require.NoError(t, w.Flush())
305308
}
306309

307310
func benchmarkInputS3(t *testing.T, numberOfWorkers int) testing.BenchmarkResult {
@@ -410,19 +413,19 @@ func TestBenchmarkInputS3(t *testing.T) {
410413
}
411414

412415
headers := []string{
413-
"Number of workers",
414-
"Objects listed total",
415-
"Objects listed per sec",
416-
"Objects processed total",
417-
"Objects processed per sec",
418-
"Objects acked total",
419-
"Objects acked per sec",
420-
"Events total",
421-
"Events per sec",
422-
"S3 Bytes total",
423-
"S3 Bytes per sec",
424-
"Time (sec)",
425-
"CPUs",
416+
"NUMBER OF WORKERS",
417+
"OBJECTS LISTED TOTAL",
418+
"OBJECTS LISTED PER SEC",
419+
"OBJECTS PROCESSED TOTAL",
420+
"OBJECTS PROCESSED PER SEC",
421+
"OBJECTS ACKED TOTAL",
422+
"OBJECTS ACKED PER SEC",
423+
"EVENTS TOTAL",
424+
"EVENTS PER SEC",
425+
"S3 BYTES TOTAL",
426+
"S3 BYTES PER SEC",
427+
"TIME (SEC)",
428+
"CPUS",
426429
}
427430
data := make([][]string, 0)
428431
for _, r := range results {
@@ -443,8 +446,10 @@ func TestBenchmarkInputS3(t *testing.T) {
443446
})
444447
}
445448

446-
table := tablewriter.NewWriter(os.Stdout)
447-
table.SetHeader(headers)
448-
table.AppendBulk(data)
449-
table.Render()
449+
w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', tabwriter.Debug)
450+
fmt.Fprintln(w, strings.Join(headers, "\t"))
451+
for _, d := range data {
452+
fmt.Fprintln(w, strings.Join(d, "\t"))
453+
}
454+
require.NoError(t, w.Flush())
450455
}

0 commit comments

Comments
 (0)