meshviewer-ffrgb output: add custom fields
This will include all configured custom fields in the meshviewer-ffrgb output under the "custom_fields" key.
This commit is contained in:
parent
1a1163aaa1
commit
70cdb53b49
|
@ -41,6 +41,7 @@ type Node struct {
|
|||
Autoupdater Autoupdater `json:"autoupdater"`
|
||||
Nproc int `json:"nproc"`
|
||||
Model string `json:"model,omitempty"`
|
||||
CustomFields map[string]interface{} `json:"custom_fields,omitempty"`
|
||||
}
|
||||
|
||||
// Firmware out of software
|
||||
|
@ -154,6 +155,12 @@ func NewNode(nodes *runtime.Nodes, n *runtime.Node) *Node {
|
|||
node.GatewayIPv6 = statistic.GatewayIPv6
|
||||
}
|
||||
}
|
||||
if customFields := n.CustomFields; customFields != nil {
|
||||
node.CustomFields = make(map[string]interface{})
|
||||
for fieldName, fieldValue := range customFields {
|
||||
node.CustomFields[fieldName] = fieldValue
|
||||
}
|
||||
}
|
||||
|
||||
// fix site to domain - if empty
|
||||
if node.DomainCode == "" {
|
||||
|
|
|
@ -58,6 +58,10 @@ func TestRegister(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
CustomFields: map[string]interface{}{
|
||||
"custom_fields": "are_custom",
|
||||
"custom_int": 3,
|
||||
},
|
||||
})
|
||||
assert.NotNil(node)
|
||||
assert.NotNil(node.Addresses)
|
||||
|
@ -66,4 +70,6 @@ func TestRegister(t *testing.T) {
|
|||
assert.Equal(13.3, node.Location.Longitude)
|
||||
assert.Equal(8.7, node.Location.Latitude)
|
||||
assert.Equal(0.74, *node.MemoryUsage)
|
||||
assert.Equal("are_custom", node.CustomFields["custom_fields"])
|
||||
assert.Equal(3, node.CustomFields["custom_int"])
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue