-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Update parsing of ip addr show (SC-723) #1183
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 | ||
| link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
| inet 127.0.0.1/8 scope host lo\ valid_lft forever preferred_lft forever | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the backslashes on lines 3 and 4 a typo?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just copied the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, nevermind. It doesn't matter what it says after |
||
| inet6 ::1/128 scope host \ valid_lft forever preferred_lft forever | ||
| 2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 | ||
| link/ether 50:7b:9d:2c:af:91 brd ff:ff:ff:ff:ff:ff | ||
| inet 192.168.2.18/24 metric 100 brd 192.168.2.255 scope global dynamic enp0s25 | ||
| valid_lft 84174sec preferred_lft 84174sec | ||
| inet6 fe80::7777:2222:1111:eeee/64 scope global | ||
| valid_lft forever preferred_lft forever | ||
| inet6 fe80::8107:2b92:867e:f8a6/64 scope link | ||
| valid_lft forever preferred_lft forever | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a little bit of manual testing with this regex and didn't spot any issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bigger this regex gets, the more it makes me question whether we should really be extending a fragile regex parsing of human-readable output of ip. While I originally weighed in to the contrary because cloud-init is supported even more broadly than just Ubuntu, I think it would probably be preferable given that we attempt to try
ip -jsonformat first, and fallback to the legacy parsing if-jsonparam is not present. This way most of the latest *nix distros with recentiptooling can benefit from simple parsing of machine-readable output and any older distributions will continue to parse correctly with the olderiptooling and output formats.