Skip to content

Commit

Permalink
Make MetricsConfig.Clone a nonpointer receiver.
Browse files Browse the repository at this point in the history
  • Loading branch information
dplepage-dd committed Jan 27, 2025
1 parent e463ed7 commit 4b927e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions pkg/networkdevice/profile/profiledefinition/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,8 @@ type MetricsConfig struct {
}

// Clone duplicates this MetricsConfig
func (m *MetricsConfig) Clone() *MetricsConfig {
if m == nil {
return nil
}
return &MetricsConfig{
func (m MetricsConfig) Clone() MetricsConfig {
return MetricsConfig{
MIB: m.MIB,
Table: m.Table.Clone(),
Symbol: m.Symbol.Clone(),
Expand Down
6 changes: 3 additions & 3 deletions pkg/networkdevice/profile/profiledefinition/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ func TestCloneMetricTagConfig(t *testing.T) {
}

func TestCloneMetricsConfig(t *testing.T) {
buildConf := func() *MetricsConfig {
return &MetricsConfig{
buildConf := func() MetricsConfig {
return MetricsConfig{
MIB: "FOO-MIB",
Table: SymbolConfig{
OID: "1.2.3.4",
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestCloneMetricsConfig(t *testing.T) {

func TestCloneEmpty(t *testing.T) {
mc := MetricsConfig{}
assert.Equal(t, &mc, mc.Clone())
assert.Equal(t, mc, mc.Clone())
sym := SymbolConfig{}
assert.Equal(t, sym, sym.Clone())
tag := MetricTagConfig{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (p *ProfileDefinition) Clone() *ProfileDefinition {
Metadata: CloneMap(p.Metadata),
MetricTags: CloneSlice(p.MetricTags),
StaticTags: slices.Clone(p.StaticTags),
Metrics: slices.Clone(p.Metrics),
Metrics: CloneSlice(p.Metrics),
Device: DeviceMeta{
Vendor: p.Device.Vendor,
},
Expand Down

0 comments on commit 4b927e9

Please sign in to comment.