generate a net status for interface (expected to be "public" or "cluster") with some number of IPs
(iface string, ips ...string)
| 803 | |
| 804 | // generate a net status for interface (expected to be "public" or "cluster") with some number of IPs |
| 805 | func netStatus(iface string, ips ...string) string { |
| 806 | ipsInJson := "" |
| 807 | for _, ip := range ips { |
| 808 | if ipsInJson != "" { |
| 809 | ipsInJson += "," |
| 810 | } |
| 811 | ipsInJson = ipsInJson + "\n" + ` "` + ip + `"` |
| 812 | } |
| 813 | out := `[{ |
| 814 | "name": "bridge", |
| 815 | "interface": "eth0", |
| 816 | "ips": [ |
| 817 | "10.244.1.152" |
| 818 | ], |
| 819 | "mac": "1a:15:5d:61:18:50", |
| 820 | "default": true, |
| 821 | "dns": {}, |
| 822 | "gateway": [ |
| 823 | "10.244.0.1" |
| 824 | ] |
| 825 | },{ |
| 826 | "name": "dont/care", |
| 827 | "interface": "` + iface + `", |
| 828 | "ips": [` + ipsInJson + ` |
| 829 | ], |
| 830 | "mac": "8e:ec:4a:e3:1b:96", |
| 831 | "dns": {} |
| 832 | }]` |
| 833 | return out |
| 834 | } |
| 835 | |
| 836 | // generate 'ip --json address show dev <iface>' output with some number of <ip>/<prefix>-es |
| 837 | // also contains extra IPv6 SLAAC addrs that are often present in containers |
no outgoing calls
no test coverage detected