Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch table writer to https://github.com/jedib0t/go-pretty #2292

Closed
hellt opened this issue Nov 13, 2024 · 4 comments
Closed

switch table writer to https://github.com/jedib0t/go-pretty #2292

hellt opened this issue Nov 13, 2024 · 4 comments

Comments

@hellt
Copy link
Member

hellt commented Nov 13, 2024

Tables are much nicer with https://github.com/jedib0t/go-pretty

I like the styling of NATS CLI tables that use this library https://github.com/nats-io/natscli/blob/392437ff9524662a5cc677b06821008ccb6ef802/cli/tables.go#L28

image
@hyposcaler-bot
Copy link
Contributor

hyposcaler-bot commented Nov 13, 2024

Looked at this for a bit, go-pretty is almost a drop in replacement. Just need to account for a few minor differences in method names, table.Row versus []string, and need to rework toTableData() in inspect.go

@hyposcaler-bot
Copy link
Contributor

hyposcaler-bot commented Nov 15, 2024

Have go-pretty working for inspect, only gap is header isn't aligned center, will work on netem output and should have a pr tomorrow. MD shows vertical lines with breaks, but they are smooth on console.

dfanshaw@midgard:~/src/containerlab/lab-examples/srl02$ sudo ~/src/containerlab/bin/containerlab inspect -w
INFO[0000] Parsing & checking topology file: srl02.clab.yml
┌───┬──────────┬─────────────────┬──────────────┬───────────────────────┬───────────────┬─────────┬────────────────┬──────────────────────┐
│ # │ Owner    │ Name            │ Container ID │ Image                 │ Kind          │ State   │ IPv4 Address   │ IPv6 Address         │
├───┼──────────┼─────────────────┼──────────────┼───────────────────────┼───────────────┼─────────┼────────────────┼──────────────────────┤
│ 1 │ dfanshaw │ clab-srl02-srl1 │ e190bc300fa6 │ ghcr.io/nokia/srlinux │ nokia_srlinux │ running │ 172.20.20.3/24 │ 3fff:172:20:20::3/64 │
│ 2 │          │ clab-srl02-srl2 │ 1c8e08179693 │ ghcr.io/nokia/srlinux │ nokia_srlinux │ running │ 172.20.20.2/24 │ 3fff:172:20:20::2/64 │
└───┴──────────┴─────────────────┴──────────────┴───────────────────────┴───────────────┴─────────┴────────────────┴──────────────────────┘
dfanshaw@midgard:~/src/containerlab/lab-examples/srl02$ sudo ~/src/containerlab/bin/containerlab inspect -a
┌───┬────────────────┬──────────┬─────────────────┬──────────────┬───────────────────────┬───────────────┬─────────┬────────────────┬──────────────────────┐
│ # │ Topo Path      │ Lab Name │ Name            │ Container ID │ Image                 │ Kind          │ State   │ IPv4 Address   │ IPv6 Address         │
├───┼────────────────┼──────────┼─────────────────┼──────────────┼───────────────────────┼───────────────┼─────────┼────────────────┼──────────────────────┤
│ 1 │ srl02.clab.yml │ srl02    │ clab-srl02-srl1 │ e190bc300fa6 │ ghcr.io/nokia/srlinux │ nokia_srlinux │ running │ 172.20.20.3/24 │ 3fff:172:20:20::3/64 │
│ 2 │                │          │ clab-srl02-srl2 │ 1c8e08179693 │ ghcr.io/nokia/srlinux │ nokia_srlinux │ running │ 172.20.20.2/24 │ 3fff:172:20:20::2/64 │
└───┴────────────────┴──────────┴─────────────────┴──────────────┴───────────────────────┴───────────────┴─────────┴────────────────┴──────────────────────┘
dfanshaw@midgard:~/src/containerlab/lab-examples/srl02$ sudo ~/src/containerlab/bin/containerlab inspect
INFO[0000] Parsing & checking topology file: srl02.clab.yml
┌───┬─────────────────┬──────────────┬───────────────────────┬───────────────┬─────────┬────────────────┬──────────────────────┐
│ # │ Name            │ Container ID │ Image                 │ Kind          │ State   │ IPv4 Address   │ IPv6 Address         │
├───┼─────────────────┼──────────────┼───────────────────────┼───────────────┼─────────┼────────────────┼──────────────────────┤
│ 1 │ clab-srl02-srl1 │ e190bc300fa6 │ ghcr.io/nokia/srlinux │ nokia_srlinux │ running │ 172.20.20.3/24 │ 3fff:172:20:20::3/64 │
│ 2 │ clab-srl02-srl2 │ 1c8e08179693 │ ghcr.io/nokia/srlinux │ nokia_srlinux │ running │ 172.20.20.2/24 │ 3fff:172:20:20::2/64 │
└───┴─────────────────┴──────────────┴───────────────────────┴───────────────┴─────────┴────────────────┴──────────────────────┘
dfanshaw@midgard:~/src/containerlab/lab-examples/srl02$

@hyposcaler-bot
Copy link
Contributor

got something in place for netem

dfanshaw@midgard:~/src/containerlab/lab-examples/srl02$ sudo ~/src/containerlab/bin/containerlab tools netem show -n clab-srl02-srl1
┌─────────────────────────┬───────┬────────┬─────────────┬─────────────┬────────────┐
│ Interface               │ Delay │ Jitter │ Packet Loss │ Rate (Kbit) │ Corruption │
├─────────────────────────┼───────┼────────┼─────────────┼─────────────┼────────────┤
│ lo                      │ N/A   │ N/A    │ N/A         │ N/A         │ N/A        │
│ mgmt0                   │ N/A   │ N/A    │ N/A         │ N/A         │ N/A        │
│ e1-1                    │ N/A   │ N/A    │ N/A         │ N/A         │ N/A        │
│ gway-2800               │ N/A   │ N/A    │ N/A         │ N/A         │ N/A        │
│ monit_in                │ N/A   │ N/A    │ N/A         │ N/A         │ N/A        │
│ mgmt0-0 (mgmt0.0)       │ N/A   │ N/A    │ N/A         │ N/A         │ N/A        │
│ gway-2801               │ N/A   │ N/A    │ N/A         │ N/A         │ N/A        │
│ e1-1-0 (ethernet-1/1.0) │ N/A   │ N/A    │ N/A         │ N/A         │ N/A        │
└─────────────────────────┴───────┴────────┴─────────────┴─────────────┴────────────┘
dfanshaw@midgard:~/src/containerlab/lab-examples/srl02$

#2296 is out for a look, should be good enough to compare with older style tables.

hellt added a commit that referenced this issue Nov 25, 2024
* replaced tablewriter with go-pretty

* variable renames

* adjusts smoke test to account for different border char

* add center alignment for headers

* remove container ID, collapse v4/v6 addresses

* squash header to 1 line

* removed number col, bolded headers

* combine kind/image and strip prefixlen from ip

* fix ip stripping func and use the latest go-pretty to use the align functionality in the headers

* topo path -> topology

* added bold color

* use the shortest file path when displaying the inspect --all (relative vs absolute)

* fix "Ensure "inspect all" outputs IP addresses" test

* wait longer for the tests running on arm/macos

* do not check if nf_tables kernel module is available in /proc/modules

this file might not be available on some VMs like OrbStack on macos, and the error will anyhow be detected when setting up a connection with the netlink socket

* fix 02-destroy test suite

* fix 05* test

* fix ext container tests

* change style for the netem table

---------

Co-authored-by: Roman Dodin <dodin.roman@gmail.com>
@hellt
Copy link
Member Author

hellt commented Nov 27, 2024

done in #2296

@hellt hellt closed this as completed Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants