mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-06 21:24:16 +08:00
fix: correct ids of static and user nodes (#3421)
- fix static and user node ids - enhance output by adding a "Type" column
This commit is contained in:
parent
df1ce61dad
commit
163b04966f
1 changed files with 26 additions and 3 deletions
|
@ -29,7 +29,7 @@ var nodeListCmd = &cobra.Command{
|
|||
functions.PrettyPrint(data)
|
||||
default:
|
||||
table := tablewriter.NewWriter(os.Stdout)
|
||||
table.SetHeader([]string{"ID", "Addresses", "Network", "Egress", "Remote Access Gateway", "Relay"})
|
||||
table.SetHeader([]string{"ID", "Addresses", "Network", "Egress", "Remote Access Gateway", "Relay", "Type"})
|
||||
for _, d := range data {
|
||||
addresses := ""
|
||||
if d.Address != "" {
|
||||
|
@ -41,8 +41,31 @@ var nodeListCmd = &cobra.Command{
|
|||
}
|
||||
addresses += d.Address6
|
||||
}
|
||||
table.Append([]string{d.ID, addresses, d.Network,
|
||||
strconv.FormatBool(d.IsEgressGateway), strconv.FormatBool(d.IsIngressGateway), strconv.FormatBool(d.IsRelay)})
|
||||
network := d.Network
|
||||
id := d.ID
|
||||
nodeType := "Device"
|
||||
|
||||
if d.IsStatic {
|
||||
id = d.StaticNode.ClientID
|
||||
nodeType = "Static"
|
||||
}
|
||||
if d.IsUserNode {
|
||||
id = d.StaticNode.OwnerID
|
||||
nodeType = "User"
|
||||
}
|
||||
if d.IsStatic || d.IsUserNode {
|
||||
addresses = d.StaticNode.Address
|
||||
if d.StaticNode.Address6 != "" {
|
||||
if addresses != "" {
|
||||
addresses += ", "
|
||||
}
|
||||
addresses += d.StaticNode.Address6
|
||||
}
|
||||
network = d.StaticNode.Network
|
||||
}
|
||||
|
||||
table.Append([]string{id, addresses, network,
|
||||
strconv.FormatBool(d.IsEgressGateway), strconv.FormatBool(d.IsIngressGateway), strconv.FormatBool(d.IsRelay), nodeType})
|
||||
}
|
||||
table.Render()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue