Use Node.Sets for Host Local Networks.

This commit is contained in:
Tom Wilkie
2015-10-27 14:35:07 +00:00
parent 6e9ad995b0
commit ec4425fb80
7 changed files with 20 additions and 18 deletions

View File

@@ -2,7 +2,6 @@ package host
import (
"runtime"
"strings"
"time"
"github.com/weaveworks/scope/report"
@@ -71,11 +70,12 @@ func (r *Reporter) Report() (report.Report, error) {
rep.Host.AddNode(report.MakeHostNodeID(r.hostID), report.MakeNodeWith(map[string]string{
Timestamp: Now(),
HostName: r.hostName,
LocalNetworks: strings.Join(localCIDRs, " "),
OS: runtime.GOOS,
Load: GetLoad(),
KernelVersion: kernel,
Uptime: uptime.String(),
}).WithSets(report.Sets{
LocalNetworks: report.MakeStringSet(localCIDRs...),
}))
return rep, nil

View File

@@ -48,11 +48,12 @@ func TestReporter(t *testing.T) {
want.Host.AddNode(report.MakeHostNodeID(hostID), report.MakeNodeWith(map[string]string{
host.Timestamp: now,
host.HostName: hostname,
host.LocalNetworks: network,
host.OS: runtime.GOOS,
host.Load: load,
host.Uptime: uptime,
host.KernelVersion: kernel,
}).WithSets(report.Sets{
host.LocalNetworks: report.MakeStringSet(network),
}))
have, _ := host.NewReporter(hostID, hostname, localNets).Report()
if !reflect.DeepEqual(want, have) {