mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-18 04:49:55 +00:00
Update topology to include tag
Tag can be used to specify the sub-shape for the given node. Signed-off-by: Akash Srivastava <akash.srivastava@openebs.io>
This commit is contained in:
@@ -60,6 +60,7 @@ class NodeContainer extends React.Component {
|
||||
<GraphNode
|
||||
id={this.props.id}
|
||||
shape={this.props.shape}
|
||||
tag={this.props.tag}
|
||||
label={this.props.label}
|
||||
labelMinor={this.props.labelMinor}
|
||||
labelOffset={labelOffset}
|
||||
|
||||
@@ -162,6 +162,7 @@ class NodesChartElements extends React.Component {
|
||||
focused={node.get('focused')}
|
||||
highlighted={node.get('highlighted')}
|
||||
shape={shape}
|
||||
tag={node.get('tag')}
|
||||
stacked={node.get('stack')}
|
||||
key={node.get('id')}
|
||||
id={node.get('id')}
|
||||
|
||||
@@ -48,6 +48,7 @@ func TestMakeDetailedHostNode(t *testing.T) {
|
||||
Rank: "hostname.com",
|
||||
Pseudo: false,
|
||||
Shape: "circle",
|
||||
Tag: "",
|
||||
},
|
||||
Adjacency: report.MakeIDList(fixture.ServerHostNodeID),
|
||||
Metadata: []report.MetadataRow{
|
||||
@@ -192,6 +193,7 @@ func TestMakeDetailedContainerNode(t *testing.T) {
|
||||
LabelMinor: "server.hostname.com",
|
||||
Rank: fixture.ServerContainerImageName,
|
||||
Shape: "hexagon",
|
||||
Tag: "",
|
||||
Pseudo: false,
|
||||
},
|
||||
Metadata: []report.MetadataRow{
|
||||
@@ -321,6 +323,7 @@ func TestMakeDetailedPodNode(t *testing.T) {
|
||||
LabelMinor: "1 container",
|
||||
Rank: "ping/pong-b",
|
||||
Shape: "heptagon",
|
||||
Tag: "",
|
||||
Pseudo: false,
|
||||
},
|
||||
Metadata: []report.MetadataRow{
|
||||
|
||||
@@ -49,6 +49,7 @@ type BasicNodeSummary struct {
|
||||
LabelMinor string `json:"labelMinor"`
|
||||
Rank string `json:"rank"`
|
||||
Shape string `json:"shape,omitempty"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Stack bool `json:"stack,omitempty"`
|
||||
Pseudo bool `json:"pseudo,omitempty"`
|
||||
}
|
||||
@@ -115,6 +116,7 @@ func MakeBasicNodeSummary(r report.Report, n report.Node) (BasicNodeSummary, boo
|
||||
}
|
||||
if t, ok := r.Topology(n.Topology); ok {
|
||||
summary.Shape = t.GetShape()
|
||||
summary.Tag = t.Tag
|
||||
}
|
||||
|
||||
// Do we have a renderer for the topology?
|
||||
@@ -399,6 +401,7 @@ func groupNodeSummary(base BasicNodeSummary, r report.Report, n report.Node) Bas
|
||||
if topology, _, ok := render.ParseGroupNodeTopology(n.Topology); ok {
|
||||
if t, ok := r.Topology(topology); ok {
|
||||
base.Shape = t.GetShape()
|
||||
base.Tag = t.Tag
|
||||
if t.Label != "" {
|
||||
base.LabelMinor = pluralize(n.Counters, topology, t.Label, t.LabelPlural)
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ func TestMakeNodeSummary(t *testing.T) {
|
||||
LabelMinor: "client.hostname.com (10001)",
|
||||
Rank: fixture.Client1Name,
|
||||
Shape: "square",
|
||||
Tag: "",
|
||||
},
|
||||
Metadata: []report.MetadataRow{
|
||||
{ID: process.PID, Label: "PID", Value: fixture.Client1PID, Priority: 1, Datatype: report.Number},
|
||||
@@ -128,6 +129,7 @@ func TestMakeNodeSummary(t *testing.T) {
|
||||
LabelMinor: fixture.ClientHostName,
|
||||
Rank: fixture.ClientContainerImageName,
|
||||
Shape: "hexagon",
|
||||
Tag: "",
|
||||
},
|
||||
Metadata: []report.MetadataRow{
|
||||
{ID: docker.ImageName, Label: "Image name", Value: fixture.ClientContainerImageName, Priority: 2},
|
||||
@@ -147,6 +149,7 @@ func TestMakeNodeSummary(t *testing.T) {
|
||||
LabelMinor: "1 container",
|
||||
Rank: fixture.ClientContainerImageName,
|
||||
Shape: "hexagon",
|
||||
Tag: "",
|
||||
Stack: true,
|
||||
},
|
||||
Metadata: []report.MetadataRow{
|
||||
@@ -166,6 +169,7 @@ func TestMakeNodeSummary(t *testing.T) {
|
||||
LabelMinor: "hostname.com",
|
||||
Rank: "hostname.com",
|
||||
Shape: "circle",
|
||||
Tag: "",
|
||||
},
|
||||
Metadata: []report.MetadataRow{
|
||||
{ID: host.HostName, Label: "Hostname", Value: fixture.ClientHostName, Priority: 11},
|
||||
@@ -184,6 +188,7 @@ func TestMakeNodeSummary(t *testing.T) {
|
||||
LabelMinor: "1 process",
|
||||
Rank: "apache",
|
||||
Shape: "square",
|
||||
Tag: "",
|
||||
Stack: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -44,6 +44,7 @@ const (
|
||||
Cylinder = "cylinder"
|
||||
DottedCylinder = "dottedcylinder"
|
||||
StorageSheet = "sheet"
|
||||
Camera = "camera"
|
||||
|
||||
// Used when counting the number of containers
|
||||
ContainersKey = "containers"
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
// in the Node struct.
|
||||
type Topology struct {
|
||||
Shape string `json:"shape,omitempty"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
LabelPlural string `json:"label_plural,omitempty"`
|
||||
Nodes Nodes `json:"nodes"`
|
||||
@@ -32,6 +33,7 @@ func MakeTopology() Topology {
|
||||
func (t Topology) WithMetadataTemplates(other MetadataTemplates) Topology {
|
||||
return Topology{
|
||||
Shape: t.Shape,
|
||||
Tag: t.Tag,
|
||||
Label: t.Label,
|
||||
LabelPlural: t.LabelPlural,
|
||||
Nodes: t.Nodes.Copy(),
|
||||
@@ -47,6 +49,7 @@ func (t Topology) WithMetadataTemplates(other MetadataTemplates) Topology {
|
||||
func (t Topology) WithMetricTemplates(other MetricTemplates) Topology {
|
||||
return Topology{
|
||||
Shape: t.Shape,
|
||||
Tag: t.Tag,
|
||||
Label: t.Label,
|
||||
LabelPlural: t.LabelPlural,
|
||||
Nodes: t.Nodes.Copy(),
|
||||
@@ -62,6 +65,7 @@ func (t Topology) WithMetricTemplates(other MetricTemplates) Topology {
|
||||
func (t Topology) WithTableTemplates(other TableTemplates) Topology {
|
||||
return Topology{
|
||||
Shape: t.Shape,
|
||||
Tag: t.Tag,
|
||||
Label: t.Label,
|
||||
LabelPlural: t.LabelPlural,
|
||||
Nodes: t.Nodes.Copy(),
|
||||
@@ -76,6 +80,22 @@ func (t Topology) WithTableTemplates(other TableTemplates) Topology {
|
||||
func (t Topology) WithShape(shape string) Topology {
|
||||
return Topology{
|
||||
Shape: shape,
|
||||
Tag: t.Tag,
|
||||
Label: t.Label,
|
||||
LabelPlural: t.LabelPlural,
|
||||
Nodes: t.Nodes.Copy(),
|
||||
Controls: t.Controls.Copy(),
|
||||
MetadataTemplates: t.MetadataTemplates.Copy(),
|
||||
MetricTemplates: t.MetricTemplates.Copy(),
|
||||
TableTemplates: t.TableTemplates.Copy(),
|
||||
}
|
||||
}
|
||||
|
||||
// WithTag sets the tag of nodes from this topology, returning a new topology.
|
||||
func (t Topology) WithTag(tag string) Topology {
|
||||
return Topology{
|
||||
Shape: t.Shape,
|
||||
Tag: tag,
|
||||
Label: t.Label,
|
||||
LabelPlural: t.LabelPlural,
|
||||
Nodes: t.Nodes.Copy(),
|
||||
@@ -90,6 +110,7 @@ func (t Topology) WithShape(shape string) Topology {
|
||||
func (t Topology) WithLabel(label, labelPlural string) Topology {
|
||||
return Topology{
|
||||
Shape: t.Shape,
|
||||
Tag: t.Tag,
|
||||
Label: label,
|
||||
LabelPlural: labelPlural,
|
||||
Nodes: t.Nodes.Copy(),
|
||||
@@ -130,6 +151,7 @@ func (t Topology) GetShape() string {
|
||||
func (t Topology) Copy() Topology {
|
||||
return Topology{
|
||||
Shape: t.Shape,
|
||||
Tag: t.Tag,
|
||||
Label: t.Label,
|
||||
LabelPlural: t.LabelPlural,
|
||||
Nodes: t.Nodes.Copy(),
|
||||
@@ -151,8 +173,13 @@ func (t Topology) Merge(other Topology) Topology {
|
||||
if label == "" {
|
||||
label, labelPlural = other.Label, other.LabelPlural
|
||||
}
|
||||
tag := t.Tag
|
||||
if tag == "" {
|
||||
tag = other.Tag
|
||||
}
|
||||
return Topology{
|
||||
Shape: shape,
|
||||
Tag: tag,
|
||||
Label: label,
|
||||
LabelPlural: labelPlural,
|
||||
Nodes: t.Nodes.Merge(other.Nodes),
|
||||
@@ -171,6 +198,9 @@ func (t *Topology) UnsafeMerge(other Topology) {
|
||||
if t.Label == "" {
|
||||
t.Label, t.LabelPlural = other.Label, other.LabelPlural
|
||||
}
|
||||
if t.Tag == "" {
|
||||
t.Tag = other.Tag
|
||||
}
|
||||
t.Nodes.UnsafeMerge(other.Nodes)
|
||||
t.Controls = t.Controls.Merge(other.Controls)
|
||||
t.MetadataTemplates = t.MetadataTemplates.Merge(other.MetadataTemplates)
|
||||
|
||||
Reference in New Issue
Block a user