Skip to content

Commit

Permalink
[TASK] rename NodeInfo to Nodeinfo (same naming overall)
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Jan 24, 2019
1 parent 27fde7c commit bd13b99
Show file tree
Hide file tree
Showing 30 changed files with 71 additions and 71 deletions.
4 changes: 2 additions & 2 deletions data/nodeinfo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package data

// NodeInfo struct
type NodeInfo struct {
// Nodeinfo struct
type Nodeinfo struct {
NodeID string `json:"node_id"`
Network Network `json:"network"`
Owner *Owner `json:"owner"`
Expand Down
2 changes: 1 addition & 1 deletion data/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package data
// ResponseData struct
type ResponseData struct {
Neighbours *Neighbours `json:"neighbours"`
NodeInfo *NodeInfo `json:"nodeinfo"`
Nodeinfo *Nodeinfo `json:"nodeinfo"`
Statistics *Statistics `json:"statistics"`
}
6 changes: 3 additions & 3 deletions database/influxdb/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func createTestNodes() *runtime.Nodes {
Total: 23,
},
},
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "abcdef012345",
Hardware: data.Hardware{
Model: "TP-Link 841",
Expand All @@ -146,7 +146,7 @@ func createTestNodes() *runtime.Nodes {
Total: 2,
},
},
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "112233445566",
Hardware: data.Hardware{
Model: "TP-Link 841",
Expand All @@ -156,7 +156,7 @@ func createTestNodes() *runtime.Nodes {

nodes.AddNode(&runtime.Node{
Online: true,
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "0xdeadbeef0x",
VPN: true,
Hardware: data.Hardware{
Expand Down
6 changes: 3 additions & 3 deletions database/influxdb/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestToInflux(t *testing.T) {
},
},
},
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "deadbeef",
Owner: &data.Owner{
Contact: "nobody",
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestToInflux(t *testing.T) {
}

neighbour := &runtime.Node{
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "foobar",
Network: data.Network{
Mac: "BAFF1E5",
Expand All @@ -117,7 +117,7 @@ func TestToInflux(t *testing.T) {

// do not add a empty statistics of a node
droppednode := &runtime.Node{
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "notfound",
Network: data.Network{
Mac: "instats",
Expand Down
2 changes: 1 addition & 1 deletion database/respondd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func Connect(configuration map[string]interface{}) (database.Connection, error)

func (conn *Connection) InsertNode(node *runtime.Node) {
res := &data.ResponseData{
NodeInfo: node.Nodeinfo,
Nodeinfo: node.Nodeinfo,
Statistics: node.Statistics,
Neighbours: node.Neighbours,
}
Expand Down
2 changes: 1 addition & 1 deletion database/respondd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestStart(t *testing.T) {
assert.NoError(err)

conn.InsertNode(&runtime.Node{
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "73deadbeaf13",
Hostname: "inject-test",
Network: data.Network{
Expand Down
6 changes: 3 additions & 3 deletions output/filter/blacklist/blacklist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ func TestFilterBlacklist(t *testing.T) {
assert.NoError(err)

// keep node without nodeid
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}})
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}})
assert.NotNil(n)

// tests with blacklist
filter, err = build([]interface{}{"a", "c"})
assert.NoError(err)

// blacklist contains node with nodeid -> drop it
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{NodeID: "a"}})
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{NodeID: "a"}})
assert.Nil(n)

// blacklist does not contains node without nodeid -> keep it
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}})
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}})
assert.NotNil(n)

n = filter.Apply(&runtime.Node{})
Expand Down
2 changes: 1 addition & 1 deletion output/filter/domainappendsite/domainappendsite.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (config *domainAppendSite) Apply(node *runtime.Node) *runtime.Node {
Lastseen: node.Lastseen,
Online: node.Online,
Statistics: node.Statistics,
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: nodeinfo.NodeID,
Network: nodeinfo.Network,
System: data.System{
Expand Down
4 changes: 2 additions & 2 deletions output/filter/domainappendsite/domainappendsite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestFilter(t *testing.T) {

// delete owner by configuration
filter, _ = build(true)
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
System: data.System{
SiteCode: "ffhb",
DomainCode: "city",
Expand All @@ -30,7 +30,7 @@ func TestFilter(t *testing.T) {

// keep owner configuration
filter, _ = build(false)
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
System: data.System{
SiteCode: "ffhb",
DomainCode: "city",
Expand Down
2 changes: 1 addition & 1 deletion output/filter/domainassite/domainassite.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (config *domainAsSite) Apply(node *runtime.Node) *runtime.Node {
Lastseen: node.Lastseen,
Online: node.Online,
Statistics: node.Statistics,
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: nodeinfo.NodeID,
Network: nodeinfo.Network,
System: data.System{
Expand Down
4 changes: 2 additions & 2 deletions output/filter/domainassite/domainassite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestFilter(t *testing.T) {

// delete owner by configuration
filter, _ = build(true)
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
System: data.System{
SiteCode: "ffhb",
DomainCode: "city",
Expand All @@ -30,7 +30,7 @@ func TestFilter(t *testing.T) {

// keep owner configuration
filter, _ = build(false)
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
System: data.System{
SiteCode: "ffhb",
DomainCode: "city",
Expand Down
4 changes: 2 additions & 2 deletions output/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestFilter(t *testing.T) {
nodes := &runtime.Nodes{
List: map[string]*runtime.Node{
"a": {
Nodeinfo: &data.NodeInfo{NodeID: "a"},
Nodeinfo: &data.Nodeinfo{NodeID: "a"},
},
},
}
Expand All @@ -83,7 +83,7 @@ func TestFilter(t *testing.T) {
nodes = &runtime.Nodes{
List: map[string]*runtime.Node{
"a": {
Nodeinfo: &data.NodeInfo{NodeID: "a"},
Nodeinfo: &data.Nodeinfo{NodeID: "a"},
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions output/filter/haslocation/haslocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ func TestFilterHasLocation(t *testing.T) {
assert.NoError(err)

// node has location (with 0,0) -> keep it
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Location: &data.Location{},
}})
assert.NotNil(n)

// node without location has no location -> drop it
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}})
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}})
assert.Nil(n)

// node without nodeinfo has no location -> drop it
Expand All @@ -38,13 +38,13 @@ func TestFilterHasLocation(t *testing.T) {
assert.NoError(err)

// node has location (with 0,0) -> drop it
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Location: &data.Location{},
}})
assert.Nil(n)

// node without location has no location -> keep it
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}})
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}})
assert.NotNil(n)

// node without nodeinfo has no location -> keep it
Expand Down
14 changes: 7 additions & 7 deletions output/filter/inarea/inarea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestFilterInArea(t *testing.T) {
"longitude_max": 12.0,
})

n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Location: &data.Location{Latitude: 4.0, Longitude: 11.0},
}})
assert.NotNil(n)
Expand All @@ -28,35 +28,35 @@ func TestFilterInArea(t *testing.T) {
assert.NotNil(n)

// keep without location -> use has_location for it
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}})
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}})
assert.NotNil(n)

// zeros not in area (0, 0)
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Location: &data.Location{},
}})
assert.Nil(n)

// in area
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Location: &data.Location{Latitude: 4.0, Longitude: 11.0},
}})
assert.NotNil(n)

// over max longitude -> dropped
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Location: &data.Location{Latitude: 4.0, Longitude: 13.0},
}})
assert.Nil(n)

// over max latitude -> dropped
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Location: &data.Location{Latitude: 6.0, Longitude: 11.0},
}})
assert.Nil(n)

// lower then mix latitde -> dropped
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Location: &data.Location{Latitude: 1.0, Longitude: 2.0},
}})
assert.Nil(n)
Expand Down
2 changes: 1 addition & 1 deletion output/filter/noowner/noowner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (no *noowner) Apply(node *runtime.Node) *runtime.Node {
Lastseen: node.Lastseen,
Online: node.Online,
Statistics: node.Statistics,
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: nodeinfo.NodeID,
Network: nodeinfo.Network,
System: nodeinfo.System,
Expand Down
4 changes: 2 additions & 2 deletions output/filter/noowner/noowner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestFilter(t *testing.T) {

// delete owner by configuration
filter, _ = build(true)
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Owner: &data.Owner{
Contact: "blub",
},
Expand All @@ -28,7 +28,7 @@ func TestFilter(t *testing.T) {

// keep owner configuration
filter, _ = build(false)
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
Owner: &data.Owner{
Contact: "blub",
},
Expand Down
4 changes: 2 additions & 2 deletions output/filter/site/site_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func TestFilterSite(t *testing.T) {
assert.NoError(err)

// wronge node
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{System: data.System{SiteCode: "ffxx"}}})
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{System: data.System{SiteCode: "ffxx"}}})
assert.Nil(n)

// right node
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{System: data.System{SiteCode: "ffhb"}}})
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{System: data.System{SiteCode: "ffhb"}}})
assert.NotNil(n)

// node without data -> wrong node
Expand Down
8 changes: 4 additions & 4 deletions output/meshviewer-ffrgb/meshviewer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestTransform(t *testing.T) {
nodes := runtime.NewNodes(&runtime.NodesConfig{})
nodes.AddNode(&runtime.Node{
Online: true,
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "node_a",
Network: data.Network{
Mac: "node:a:mac",
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestTransform(t *testing.T) {
})
nodes.AddNode(&runtime.Node{
Online: true,
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "node_c",
Network: data.Network{
Mac: "node:c:mac",
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestTransform(t *testing.T) {
})
nodes.AddNode(&runtime.Node{
Online: true,
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "node_b",
Network: data.Network{
Mac: "node:b:mac",
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestTransform(t *testing.T) {
})
nodes.AddNode(&runtime.Node{
Online: false,
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
NodeID: "node_d",
Network: data.Network{
Mac: "node:d:mac",
Expand Down
4 changes: 2 additions & 2 deletions output/meshviewer-ffrgb/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestRegister(t *testing.T) {
assert := assert.New(t)
nodes := runtime.NewNodes(&runtime.NodesConfig{})
node := NewNode(nodes, &runtime.Node{
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
Owner: &data.Owner{
Contact: "whoami",
},
Expand All @@ -26,7 +26,7 @@ func TestRegister(t *testing.T) {
assert.Len(node.Addresses, 1)

node = NewNode(nodes, &runtime.Node{
Nodeinfo: &data.NodeInfo{
Nodeinfo: &data.Nodeinfo{
Owner: &data.Owner{
Contact: "whoami",
},
Expand Down
4 changes: 2 additions & 2 deletions output/meshviewer/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type TestNode struct {
Nodeinfo *data.NodeInfo `json:"nodeinfo"`
Nodeinfo *data.Nodeinfo `json:"nodeinfo"`
Neighbours *data.Neighbours `json:"neighbours"`
}

Expand All @@ -38,7 +38,7 @@ func testGetNodesByFile(files ...string) *runtime.Nodes {
for _, file := range files {
node := testGetNodeByFile(file)
nodes.Update(file, &data.ResponseData{
NodeInfo: node.Nodeinfo,
Nodeinfo: node.Nodeinfo,
Neighbours: node.Neighbours,
})
}
Expand Down
2 changes: 1 addition & 1 deletion output/meshviewer/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Node struct {
Lastseen jsontime.Time `json:"lastseen"`
Flags Flags `json:"flags"`
Statistics *Statistics `json:"statistics"`
Nodeinfo *data.NodeInfo `json:"nodeinfo"`
Nodeinfo *data.Nodeinfo `json:"nodeinfo"`
Neighbours *data.Neighbours `json:"-"`
}

Expand Down
Loading

0 comments on commit bd13b99

Please sign in to comment.