[BUGFIX] meshviewer-ffrgb export empty array
This commit is contained in:
parent
6579d52bac
commit
f5d0067eff
@ -78,15 +78,18 @@ func NewNode(nodes *runtime.Nodes, n *runtime.Node) *Node {
|
|||||||
Lastseen: n.Lastseen,
|
Lastseen: n.Lastseen,
|
||||||
IsOnline: n.Online,
|
IsOnline: n.Online,
|
||||||
IsGateway: n.IsGateway(),
|
IsGateway: n.IsGateway(),
|
||||||
|
Addresses: []string{},
|
||||||
}
|
}
|
||||||
|
|
||||||
if nodeinfo := n.Nodeinfo; nodeinfo != nil {
|
if nodeinfo := n.Nodeinfo; nodeinfo != nil {
|
||||||
node.NodeID = nodeinfo.NodeID
|
node.NodeID = nodeinfo.NodeID
|
||||||
node.MAC = nodeinfo.Network.Mac
|
node.MAC = nodeinfo.Network.Mac
|
||||||
node.Addresses = nodeinfo.Network.Addresses
|
|
||||||
node.SiteCode = nodeinfo.System.SiteCode
|
node.SiteCode = nodeinfo.System.SiteCode
|
||||||
node.DomainCode = nodeinfo.System.DomainCode
|
node.DomainCode = nodeinfo.System.DomainCode
|
||||||
node.Hostname = nodeinfo.Hostname
|
node.Hostname = nodeinfo.Hostname
|
||||||
|
if addresses := nodeinfo.Network.Addresses; addresses != nil {
|
||||||
|
node.Addresses = nodeinfo.Network.Addresses
|
||||||
|
}
|
||||||
if owner := nodeinfo.Owner; owner != nil {
|
if owner := nodeinfo.Owner; owner != nil {
|
||||||
node.Owner = owner.Contact
|
node.Owner = owner.Contact
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,20 @@ func TestRegister(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
||||||
node := NewNode(nodes, &runtime.Node{
|
node := NewNode(nodes, &runtime.Node{
|
||||||
|
Nodeinfo: &data.NodeInfo{
|
||||||
|
Owner: &data.Owner{
|
||||||
|
Contact: "whoami",
|
||||||
|
},
|
||||||
|
Network: data.Network{
|
||||||
|
Mac: "blub",
|
||||||
|
Addresses: []string{"fe80::1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
assert.NotNil(node)
|
||||||
|
assert.Len(node.Addresses, 1)
|
||||||
|
|
||||||
|
node = NewNode(nodes, &runtime.Node{
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.NodeInfo{
|
||||||
Owner: &data.Owner{
|
Owner: &data.Owner{
|
||||||
Contact: "whoami",
|
Contact: "whoami",
|
||||||
@ -46,6 +60,7 @@ func TestRegister(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
assert.NotNil(node)
|
assert.NotNil(node)
|
||||||
|
assert.NotNil(node.Addresses)
|
||||||
assert.Equal("whoami", node.Owner)
|
assert.Equal("whoami", node.Owner)
|
||||||
assert.Equal("blub", node.MAC)
|
assert.Equal("blub", node.MAC)
|
||||||
assert.Equal(13.3, node.Location.Longitude)
|
assert.Equal(13.3, node.Location.Longitude)
|
||||||
|
Loading…
Reference in New Issue
Block a user