Skip to content

Commit

Permalink
Renamed probes Table -> PropertyList
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarl committed Dec 21, 2016
1 parent bae1533 commit 8e51f80
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 363 deletions.
18 changes: 10 additions & 8 deletions client/app/scripts/components/node-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,22 @@ class NodeDetails extends React.Component {
</div>
))}

{details.tables && details.tables.length > 0 && details.tables.map((table) => {
if (table.rows.length > 0) {
{details.propertyLists && details.propertyLists.map((propertyList) => {
if (propertyList.rows.length > 0) {
return (
<div className="node-details-content-section" key={table.id}>
<div className="node-details-content-section" key={propertyList.id}>
<div className="node-details-content-section-header">
{table.label}
{table.truncationCount > 0 && <span
{propertyList.label}
{propertyList.truncationCount > 0 && <span
className="node-details-content-section-header-warning">
<Warning text={getTruncationText(table.truncationCount)} />
<Warning text={getTruncationText(propertyList.truncationCount)} />
</span>}
</div>
<NodeDetailsLabels
rows={table.rows} controls={table.controls}
matches={nodeMatches.get('tables')} />
rows={propertyList.rows}
controls={propertyList.controls}
matches={nodeMatches.get('propertyLists')}
/>
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions probe/docker/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ func (c *container) getBaseNode() report.Node {
}).WithParents(report.EmptySets.
Add(report.ContainerImage, report.MakeStringSet(report.MakeContainerImageNodeID(c.Image()))),
)
result = result.AddPrefixTable(LabelPrefix, c.container.Config.Labels)
result = result.AddPrefixTable(EnvPrefix, c.env())
result = result.AddPrefixPropertyList(LabelPrefix, c.container.Config.Labels)
result = result.AddPrefixPropertyList(EnvPrefix, c.env())
return result
}

Expand Down
12 changes: 6 additions & 6 deletions probe/docker/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ var (
report.Container: {ID: report.Container, Label: "# Containers", From: report.FromCounters, Datatype: "number", Priority: 2},
}

ContainerTableTemplates = report.TableTemplates{
ContainerPropertyListTemplates = report.PropertyListTemplates{
ImageTableID: {ID: ImageTableID, Label: "Image",
FixedRows: map[string]string{
FixedProperties: map[string]string{
ImageID: "ID",
ImageName: "Name",
ImageSize: "Size",
Expand All @@ -60,7 +60,7 @@ var (
EnvPrefix: {ID: EnvPrefix, Label: "Environment Variables", Prefix: EnvPrefix},
}

ContainerImageTableTemplates = report.TableTemplates{
ContainerImagePropertyListTemplates = report.PropertyListTemplates{
ImageLabelPrefix: {ID: ImageLabelPrefix, Label: "Docker Labels", Prefix: ImageLabelPrefix},
}

Expand Down Expand Up @@ -181,7 +181,7 @@ func (r *Reporter) containerTopology(localAddrs []net.IP) report.Topology {
result := report.MakeTopology().
WithMetadataTemplates(ContainerMetadataTemplates).
WithMetricTemplates(ContainerMetricTemplates).
WithTableTemplates(ContainerTableTemplates)
WithPropertyListTemplates(ContainerPropertyListTemplates)
result.Controls.AddControls(ContainerControls)

metadata := map[string]string{report.ControlProbeID: r.probeID}
Expand Down Expand Up @@ -244,7 +244,7 @@ func (r *Reporter) containerTopology(localAddrs []net.IP) report.Topology {
func (r *Reporter) containerImageTopology() report.Topology {
result := report.MakeTopology().
WithMetadataTemplates(ContainerImageMetadataTemplates).
WithTableTemplates(ContainerImageTableTemplates)
WithPropertyListTemplates(ContainerImagePropertyListTemplates)

r.registry.WalkImages(func(image docker_client.APIImages) {
imageID := trimImageID(image.ID)
Expand All @@ -258,7 +258,7 @@ func (r *Reporter) containerImageTopology() report.Topology {
}
nodeID := report.MakeContainerImageNodeID(imageID)
node := report.MakeNodeWith(nodeID, latests)
node = node.AddPrefixTable(ImageLabelPrefix, image.Labels)
node = node.AddPrefixPropertyList(ImageLabelPrefix, image.Labels)
result.AddNode(node)
})

Expand Down
2 changes: 1 addition & 1 deletion probe/kubernetes/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ func (m meta) MetaNode(id string) report.Node {
Name: m.Name(),
Namespace: m.Namespace(),
Created: m.Created(),
}).AddPrefixTable(LabelPrefix, m.Labels())
}).AddPrefixPropertyList(LabelPrefix, m.Labels())
}
10 changes: 5 additions & 5 deletions probe/kubernetes/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var (

ReplicaSetMetricTemplates = PodMetricTemplates

TableTemplates = report.TableTemplates{
PropertyListTemplates = report.PropertyListTemplates{
LabelPrefix: {ID: LabelPrefix, Label: "Kubernetes Labels", Prefix: LabelPrefix},
}

Expand Down Expand Up @@ -223,7 +223,7 @@ func (r *Reporter) serviceTopology() (report.Topology, []Service, error) {
result = report.MakeTopology().
WithMetadataTemplates(ServiceMetadataTemplates).
WithMetricTemplates(ServiceMetricTemplates).
WithTableTemplates(TableTemplates)
WithPropertyListTemplates(PropertyListTemplates)
services = []Service{}
)
err := r.client.WalkServices(func(s Service) error {
Expand Down Expand Up @@ -258,7 +258,7 @@ func (r *Reporter) deploymentTopology(probeID string) (report.Topology, []Deploy
result = report.MakeTopology().
WithMetadataTemplates(DeploymentMetadataTemplates).
WithMetricTemplates(DeploymentMetricTemplates).
WithTableTemplates(TableTemplates)
WithPropertyListTemplates(PropertyListTemplates)
deployments = []Deployment{}
)
result.Controls.AddControls(ScalingControls)
Expand All @@ -276,7 +276,7 @@ func (r *Reporter) replicaSetTopology(probeID string, deployments []Deployment)
result = report.MakeTopology().
WithMetadataTemplates(ReplicaSetMetadataTemplates).
WithMetricTemplates(ReplicaSetMetricTemplates).
WithTableTemplates(TableTemplates)
WithPropertyListTemplates(PropertyListTemplates)
replicaSets = []ReplicaSet{}
selectors = []func(labelledChild){}
)
Expand Down Expand Up @@ -355,7 +355,7 @@ func (r *Reporter) podTopology(services []Service, replicaSets []ReplicaSet) (re
pods = report.MakeTopology().
WithMetadataTemplates(PodMetadataTemplates).
WithMetricTemplates(PodMetricTemplates).
WithTableTemplates(TableTemplates)
WithPropertyListTemplates(PropertyListTemplates)
selectors = []func(labelledChild){}
)
pods.Controls.AddControl(report.Control{
Expand Down
79 changes: 40 additions & 39 deletions probe/overlay/weave.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,35 @@ import (

// Keys for use in Node
const (
WeavePeerName = "weave_peer_name"
WeavePeerNickName = "weave_peer_nick_name"
WeaveDNSHostname = "weave_dns_hostname"
WeaveMACAddress = "weave_mac_address"
WeaveVersion = "weave_version"
WeaveEncryption = "weave_encryption"
WeaveProtocol = "weave_protocol"
WeavePeerDiscovery = "weave_peer_discovery"
WeaveTargetCount = "weave_target_count"
WeaveConnectionCount = "weave_connection_count"
WeavePeerCount = "weave_peer_count"
WeaveTrustedSubnets = "weave_trusted_subnet_count"
WeaveIPAMTableID = "weave_ipam_table"
WeaveIPAMStatus = "weave_ipam_status"
WeaveIPAMRange = "weave_ipam_range"
WeaveIPAMDefaultSubnet = "weave_ipam_default_subnet"
WeaveDNSTableID = "weave_dns_table"
WeaveDNSDomain = "weave_dns_domain"
WeaveDNSUpstream = "weave_dns_upstream"
WeaveDNSTTL = "weave_dns_ttl"
WeaveDNSEntryCount = "weave_dns_entry_count"
WeaveProxyTableID = "weave_proxy_table"
WeaveProxyStatus = "weave_proxy_status"
WeaveProxyAddress = "weave_proxy_address"
WeavePluginTableID = "weave_plugin_table"
WeavePluginStatus = "weave_plugin_status"
WeavePluginDriver = "weave_plugin_driver"
WeaveConnectionsTablePrefix = "weave_connections_table_"
WeavePeerName = "weave_peer_name"
WeavePeerNickName = "weave_peer_nick_name"
WeaveDNSHostname = "weave_dns_hostname"
WeaveMACAddress = "weave_mac_address"
WeaveVersion = "weave_version"
WeaveEncryption = "weave_encryption"
WeaveProtocol = "weave_protocol"
WeavePeerDiscovery = "weave_peer_discovery"
WeaveTargetCount = "weave_target_count"
WeaveConnectionCount = "weave_connection_count"
WeavePeerCount = "weave_peer_count"
WeaveTrustedSubnets = "weave_trusted_subnet_count"
WeaveIPAMTableID = "weave_ipam_table"
WeaveIPAMStatus = "weave_ipam_status"
WeaveIPAMRange = "weave_ipam_range"
WeaveIPAMDefaultSubnet = "weave_ipam_default_subnet"
WeaveDNSTableID = "weave_dns_table"
WeaveDNSDomain = "weave_dns_domain"
WeaveDNSUpstream = "weave_dns_upstream"
WeaveDNSTTL = "weave_dns_ttl"
WeaveDNSEntryCount = "weave_dns_entry_count"
WeaveProxyTableID = "weave_proxy_table"
WeaveProxyStatus = "weave_proxy_status"
WeaveProxyAddress = "weave_proxy_address"
WeavePluginTableID = "weave_plugin_table"
WeavePluginStatus = "weave_plugin_status"
WeavePluginDriver = "weave_plugin_driver"
// TODO: Change the string to "weave_connections_list" before merging
WeaveConnectionsListPrefix = "weave_connections_table_"
)

var (
Expand All @@ -72,38 +73,38 @@ var (
WeaveTrustedSubnets: {ID: WeaveTrustedSubnets, Label: "Trusted Subnets", From: report.FromSets, Priority: 9},
}

weaveTableTemplates = report.TableTemplates{
weavePropertyListTemplates = report.PropertyListTemplates{
WeaveIPAMTableID: {ID: WeaveIPAMTableID, Label: "IPAM",
FixedRows: map[string]string{
FixedProperties: map[string]string{
WeaveIPAMStatus: "Status",
WeaveIPAMRange: "Range",
WeaveIPAMDefaultSubnet: "Default Subnet",
},
},
WeaveDNSTableID: {ID: WeaveDNSTableID, Label: "DNS",
FixedRows: map[string]string{
FixedProperties: map[string]string{
WeaveDNSDomain: "Domain",
WeaveDNSUpstream: "Upstream",
WeaveDNSTTL: "TTL",
WeaveDNSEntryCount: "Entries",
},
},
WeaveProxyTableID: {ID: WeaveProxyTableID, Label: "Proxy",
FixedRows: map[string]string{
FixedProperties: map[string]string{
WeaveProxyStatus: "Status",
WeaveProxyAddress: "Address",
},
},
WeavePluginTableID: {ID: WeavePluginTableID, Label: "Plugin",
FixedRows: map[string]string{
FixedProperties: map[string]string{
WeavePluginStatus: "Status",
WeavePluginDriver: "Driver Name",
},
},
WeaveConnectionsTablePrefix: {
ID: WeaveConnectionsTablePrefix,
WeaveConnectionsListPrefix: {
ID: WeaveConnectionsListPrefix,
Label: "Connections",
Prefix: WeaveConnectionsTablePrefix,
Prefix: WeaveConnectionsListPrefix,
},
}
)
Expand Down Expand Up @@ -345,7 +346,7 @@ func (w *Weave) Report() (report.Report, error) {

r := report.MakeReport()
r.Container = r.Container.WithMetadataTemplates(containerMetadata)
r.Overlay = r.Overlay.WithMetadataTemplates(weaveMetadata).WithTableTemplates(weaveTableTemplates)
r.Overlay = r.Overlay.WithMetadataTemplates(weaveMetadata).WithPropertyListTemplates(weavePropertyListTemplates)

// We report nodes for all peers (not just the current node) to highlight peers not monitored by Scope
// (i.e. without a running probe)
Expand Down Expand Up @@ -434,13 +435,13 @@ func (w *Weave) addCurrentPeerInfo(latests map[string]string, node report.Node)
latests[WeavePluginStatus] = "running"
latests[WeavePluginDriver] = "weave"
}
node = node.AddPrefixTable(WeaveConnectionsTablePrefix, getConnectionsTable(w.statusCache.Router))
node = node.AddPrefixPropertyList(WeaveConnectionsListPrefix, getConnectionsList(w.statusCache.Router))
node = node.WithParents(report.EmptySets.Add(report.Host, report.MakeStringSet(w.hostID)))

return latests, node
}

func getConnectionsTable(router weave.Router) map[string]string {
func getConnectionsList(router weave.Router) map[string]string {
const (
outboundArrow = "->"
inboundArrow = "<-"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import (
"github.com/weaveworks/scope/report"
)

// NodeTables produces a list of tables (to be consumed directly by the UI) based
// on the report and the node. It uses the report to get the templates for the node's
// topology.
func NodeTables(r report.Report, n report.Node) []report.Table {
// NodePropertyLists produces a list of property lists (to be consumed directly by the UI) based
// on the report and the node. It uses the report to get the templates for the node's topology.
func NodePropertyLists(r report.Report, n report.Node) []report.PropertyList {
if _, ok := n.Counters.Lookup(n.Topology); ok {
// This is a group of nodes, so no tables!
return nil
}

if topology, ok := r.Topology(n.Topology); ok {
return topology.TableTemplates.Tables(n)
return topology.PropertyListTemplates.PropertyLists(n)
}
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import (
"github.com/weaveworks/scope/test/fixture"
)

func TestNodeTables(t *testing.T) {
func TestNodePropertyLists(t *testing.T) {
inputs := []struct {
name string
rpt report.Report
node report.Node
want []report.Table
want []report.PropertyList
}{
{
name: "container",
rpt: report.Report{
Container: report.MakeTopology().
WithTableTemplates(docker.ContainerTableTemplates),
WithPropertyListTemplates(docker.ContainerPropertyListTemplates),
},
node: report.MakeNodeWith(fixture.ClientContainerNodeID, map[string]string{
docker.ContainerID: fixture.ClientContainerID,
Expand All @@ -31,7 +31,7 @@ func TestNodeTables(t *testing.T) {
}).WithTopology(report.Container).WithSets(report.EmptySets.
Add(docker.ContainerIPs, report.MakeStringSet("10.10.10.0/24", "10.10.10.1/24")),
),
want: []report.Table{
want: []report.PropertyList{
{
ID: docker.EnvPrefix,
Label: "Environment Variables",
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestNodeTables(t *testing.T) {
},
}
for _, input := range inputs {
have := detailed.NodeTables(input.rpt, input.node)
have := detailed.NodePropertyLists(input.rpt, input.node)
if !reflect.DeepEqual(input.want, have) {
t.Errorf("%s: %s", input.name, test.Diff(input.want, have))
}
Expand Down
42 changes: 21 additions & 21 deletions render/detailed/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ type Column struct {

// NodeSummary is summary information about a child for a Node.
type NodeSummary struct {
ID string `json:"id"`
Label string `json:"label"`
LabelMinor string `json:"labelMinor"`
Rank string `json:"rank"`
Shape string `json:"shape,omitempty"`
Stack bool `json:"stack,omitempty"`
Linkable bool `json:"linkable,omitempty"` // Whether this node can be linked-to
Pseudo bool `json:"pseudo,omitempty"`
Metadata []report.MetadataRow `json:"metadata,omitempty"`
Parents []Parent `json:"parents,omitempty"`
Metrics []report.MetricRow `json:"metrics,omitempty"`
Tables []report.Table `json:"tables,omitempty"`
Adjacency report.IDList `json:"adjacency,omitempty"`
ID string `json:"id"`
Label string `json:"label"`
LabelMinor string `json:"labelMinor"`
Rank string `json:"rank"`
Shape string `json:"shape,omitempty"`
Stack bool `json:"stack,omitempty"`
Linkable bool `json:"linkable,omitempty"` // Whether this node can be linked-to
Pseudo bool `json:"pseudo,omitempty"`
Metadata []report.MetadataRow `json:"metadata,omitempty"`
Parents []Parent `json:"parents,omitempty"`
Metrics []report.MetricRow `json:"metrics,omitempty"`
PropertyLists []report.PropertyList `json:"propertyLists,omitempty"`
Adjacency report.IDList `json:"adjacency,omitempty"`
}

var renderers = map[string]func(NodeSummary, report.Node) (NodeSummary, bool){
Expand Down Expand Up @@ -106,14 +106,14 @@ func (n NodeSummary) SummarizeMetrics() NodeSummary {
func baseNodeSummary(r report.Report, n report.Node) NodeSummary {
t, _ := r.Topology(n.Topology)
return NodeSummary{
ID: n.ID,
Shape: t.GetShape(),
Linkable: true,
Metadata: NodeMetadata(r, n),
Metrics: NodeMetrics(r, n),
Parents: Parents(r, n),
Tables: NodeTables(r, n),
Adjacency: n.Adjacency,
ID: n.ID,
Shape: t.GetShape(),
Linkable: true,
Metadata: NodeMetadata(r, n),
Metrics: NodeMetrics(r, n),
Parents: Parents(r, n),
PropertyLists: NodePropertyLists(r, n),
Adjacency: n.Adjacency,
}
}

Expand Down
Loading

0 comments on commit 8e51f80

Please sign in to comment.