From 918b279b23af5b526ec5ad6801feca829e3e47b6 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Sat, 4 Nov 2017 20:22:22 +0100 Subject: [PATCH] [TASK] Reduce network depth in meshviewer output --- output/meshviewer-ffrgb/struct.go | 14 ++++---------- output/meshviewer-ffrgb/struct_test.go | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/output/meshviewer-ffrgb/struct.go b/output/meshviewer-ffrgb/struct.go index d5ee5e0..71381de 100644 --- a/output/meshviewer-ffrgb/struct.go +++ b/output/meshviewer-ffrgb/struct.go @@ -30,7 +30,8 @@ type Node struct { GatewayIPv4 string `json:"gateway,omitempty"` GatewayIPv6 string `json:"gateway6,omitempty"` NodeID string `json:"node_id"` - Network Network `json:"network"` + MAC string `json:"mac"` + Addresses []string `json:"addresses"` SiteCode string `json:"site_code,omitempty"` Hostname string `json:"hostname"` Owner string `json:"owner,omitempty"` @@ -54,11 +55,6 @@ type Autoupdater struct { Branch string `json:"branch,omitempty"` } -// Network struct -type Network struct { - MAC string `json:"mac"` - Addresses []string `json:"addresses"` -} // Location struct type Location struct { @@ -88,10 +84,8 @@ func NewNode(nodes *runtime.Nodes, n *runtime.Node) *Node { if nodeinfo := n.Nodeinfo; nodeinfo != nil { node.NodeID = nodeinfo.NodeID - node.Network = Network{ - MAC: nodeinfo.Network.Mac, - Addresses: nodeinfo.Network.Addresses, - } + node.MAC = nodeinfo.Network.Mac + node.Addresses = nodeinfo.Network.Addresses node.SiteCode = nodeinfo.System.SiteCode node.Hostname = nodeinfo.Hostname if owner := nodeinfo.Owner; owner != nil { diff --git a/output/meshviewer-ffrgb/struct_test.go b/output/meshviewer-ffrgb/struct_test.go index fce1e69..a95daf8 100644 --- a/output/meshviewer-ffrgb/struct_test.go +++ b/output/meshviewer-ffrgb/struct_test.go @@ -47,7 +47,7 @@ func TestRegister(t *testing.T) { }) assert.NotNil(node) assert.Equal("whoami", node.Owner) - assert.Equal("blub", node.Network.MAC) + assert.Equal("blub", node.MAC) assert.Equal(13.3, node.Location.Longtitude) assert.Equal(8.7, node.Location.Latitude) assert.Equal(0.74, *node.MemoryUsage)