mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-27 17:21:34 +00:00
refactor: remove unnecessary Copy() code
This commit is contained in:
@@ -47,29 +47,3 @@ func TestNodeMetadata(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMetadataRowCopy(t *testing.T) {
|
||||
var (
|
||||
row = report.MetadataRow{
|
||||
ID: "id",
|
||||
Value: "value",
|
||||
Priority: 1,
|
||||
Datatype: "datatype",
|
||||
}
|
||||
cp = row.Copy()
|
||||
)
|
||||
|
||||
// copy should be identical
|
||||
if !reflect.DeepEqual(row, cp) {
|
||||
t.Error(test.Diff(row, cp))
|
||||
}
|
||||
|
||||
// changing the copy should not change the original
|
||||
cp.ID = ""
|
||||
cp.Value = ""
|
||||
cp.Priority = 2
|
||||
cp.Datatype = ""
|
||||
if row.ID != "id" || row.Value != "value" || row.Priority != 1 || row.Datatype != "datatype" {
|
||||
t.Errorf("Expected changing the copy not to modify the original")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,6 @@ type MetadataTemplate struct {
|
||||
From string `json:"from,omitempty"` // Defines how to get the value from a report node
|
||||
}
|
||||
|
||||
// Copy returns a value-copy of the template
|
||||
func (t MetadataTemplate) Copy() MetadataTemplate {
|
||||
return t
|
||||
}
|
||||
|
||||
// MetadataRows returns the rows for a node
|
||||
func (t MetadataTemplate) MetadataRows(n Node) []MetadataRow {
|
||||
from := fromDefault
|
||||
@@ -90,11 +85,6 @@ type MetadataRow struct {
|
||||
Truncate int `json:"truncate,omitempty"`
|
||||
}
|
||||
|
||||
// Copy returns a value copy of a metadata row.
|
||||
func (m MetadataRow) Copy() MetadataRow {
|
||||
return m
|
||||
}
|
||||
|
||||
// MetadataTemplates is a mergeable set of metadata templates
|
||||
type MetadataTemplates map[string]MetadataTemplate
|
||||
|
||||
@@ -115,7 +105,7 @@ func (e MetadataTemplates) Copy() MetadataTemplates {
|
||||
}
|
||||
result := MetadataTemplates{}
|
||||
for k, v := range e {
|
||||
result[k] = v.Copy()
|
||||
result[k] = v
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -34,11 +34,6 @@ func (t MetricTemplate) MetricRows(n Node) []MetricRow {
|
||||
return []MetricRow{row}
|
||||
}
|
||||
|
||||
// Copy returns a value-copy of the metric template
|
||||
func (t MetricTemplate) Copy() MetricTemplate {
|
||||
return t
|
||||
}
|
||||
|
||||
// MetricTemplates is a mergeable set of metric templates
|
||||
type MetricTemplates map[string]MetricTemplate
|
||||
|
||||
@@ -59,7 +54,7 @@ func (e MetricTemplates) Copy() MetricTemplates {
|
||||
}
|
||||
result := MetricTemplates{}
|
||||
for k, v := range e {
|
||||
result[k] = v.Copy()
|
||||
result[k] = v
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ func PruneNode(node report.Node) report.Node {
|
||||
return report.MakeNode(
|
||||
node.ID).
|
||||
WithTopology(node.Topology).
|
||||
WithAdjacent(node.Adjacency.Copy()...).
|
||||
WithAdjacent(node.Adjacency...).
|
||||
WithChildren(prunedChildren)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user