Skip to content

Commit b8d9fdc

Browse files
Rename gnmiext.Configurable to DataElement
The Configurable interface is used for both configuration and state data, making the old name misleading. Rename it to DataElement, the term used by the gNMI specification for any item addressable by a path — regardless of whether it represents a leaf, container, or entire subtree. Update variable names in the nxos provider package to reflect the intent of each call site: `updates` for Update, `deletes` for Delete, `patches` for Patch, and `el` for generic slices, replacing the ambiguous `conf` that implied configuration-only usage.
1 parent debe02c commit b8d9fdc

32 files changed

Lines changed: 295 additions & 292 deletions

internal/provider/cisco/iosxr/provider_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121

2222
type TestCase struct {
2323
name string
24-
val gnmiext.Configurable
24+
val gnmiext.DataElement
2525
}
2626

2727
var tests []TestCase
2828

29-
func Register(name string, val gnmiext.Configurable) {
29+
func Register(name string, val gnmiext.DataElement) {
3030
tests = append(tests, TestCase{
3131
name: name,
3232
val: val,
@@ -92,11 +92,11 @@ func Test_Payload(t *testing.T) {
9292
type MockClient struct {
9393
// Function fields for mocking different methods
9494
CapabilitiesFunc func() *gnmiext.Capabilities
95-
GetConfigFunc func(ctx context.Context, conf ...gnmiext.Configurable) error
96-
PatchFunc func(ctx context.Context, conf ...gnmiext.Configurable) error
97-
UpdateFunc func(ctx context.Context, conf ...gnmiext.Configurable) error
98-
DeleteFunc func(ctx context.Context, conf ...gnmiext.Configurable) error
99-
GetStateFunc func(ctx context.Context, conf ...gnmiext.Configurable) error
95+
GetConfigFunc func(ctx context.Context, configs ...gnmiext.DataElement) error
96+
PatchFunc func(ctx context.Context, patches ...gnmiext.DataElement) error
97+
UpdateFunc func(ctx context.Context, updates ...gnmiext.DataElement) error
98+
DeleteFunc func(ctx context.Context, deletes ...gnmiext.DataElement) error
99+
GetStateFunc func(ctx context.Context, states ...gnmiext.DataElement) error
100100
}
101101

102102
var _ gnmiext.Client = (*MockClient)(nil)
@@ -109,37 +109,37 @@ func (m *MockClient) Capabilities() *gnmiext.Capabilities {
109109
return nil
110110
}
111111

112-
func (m *MockClient) GetConfig(ctx context.Context, conf ...gnmiext.Configurable) error {
112+
func (m *MockClient) GetConfig(ctx context.Context, configs ...gnmiext.DataElement) error {
113113
if m.GetConfigFunc != nil {
114-
return m.GetConfigFunc(ctx, conf...)
114+
return m.GetConfigFunc(ctx, configs...)
115115
}
116116
return nil
117117
}
118118

119-
func (m *MockClient) GetState(ctx context.Context, conf ...gnmiext.Configurable) error {
119+
func (m *MockClient) GetState(ctx context.Context, states ...gnmiext.DataElement) error {
120120
if m.GetStateFunc != nil {
121-
return m.GetStateFunc(ctx, conf...)
121+
return m.GetStateFunc(ctx, states...)
122122
}
123123
return nil
124124
}
125125

126-
func (m *MockClient) Patch(ctx context.Context, conf ...gnmiext.Configurable) error {
126+
func (m *MockClient) Patch(ctx context.Context, patches ...gnmiext.DataElement) error {
127127
if m.PatchFunc != nil {
128-
return m.PatchFunc(ctx, conf...)
128+
return m.PatchFunc(ctx, patches...)
129129
}
130130
return nil
131131
}
132132

133-
func (m *MockClient) Update(ctx context.Context, conf ...gnmiext.Configurable) error {
133+
func (m *MockClient) Update(ctx context.Context, updates ...gnmiext.DataElement) error {
134134
if m.UpdateFunc != nil {
135-
return m.UpdateFunc(ctx, conf...)
135+
return m.UpdateFunc(ctx, updates...)
136136
}
137137
return nil
138138
}
139139

140-
func (m *MockClient) Delete(ctx context.Context, conf ...gnmiext.Configurable) error {
140+
func (m *MockClient) Delete(ctx context.Context, deletes ...gnmiext.DataElement) error {
141141
if m.DeleteFunc != nil {
142-
return m.DeleteFunc(ctx, conf...)
142+
return m.DeleteFunc(ctx, deletes...)
143143
}
144144
return nil
145145
}
@@ -187,8 +187,8 @@ func Test_EnsureInterface(t *testing.T) {
187187

188188
func Test_GetState(t *testing.T) {
189189
m := &MockClient{
190-
GetStateFunc: func(ctx context.Context, conf ...gnmiext.Configurable) error {
191-
conf[0].(*PhysIfState).State = "im-state-up"
190+
GetStateFunc: func(ctx context.Context, states ...gnmiext.DataElement) error {
191+
states[0].(*PhysIfState).State = "im-state-up"
192192
return nil
193193
},
194194
}

internal/provider/cisco/nxos/acl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/ironcore-dev/network-operator/internal/transport/gnmiext"
1111
)
1212

13-
var _ gnmiext.Configurable = (*ACL)(nil)
13+
var _ gnmiext.DataElement = (*ACL)(nil)
1414

1515
// ACL represents an IPv4 or IPv6 access control list, depending on the rules it contains.
1616
// It can only contain either IPv4 or IPv6 rules, never both. It's name must be unique

internal/provider/cisco/nxos/banner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
)
1212

1313
var (
14-
_ gnmiext.Configurable = (*Banner)(nil)
15-
_ gnmiext.Defaultable = (*Banner)(nil)
14+
_ gnmiext.DataElement = (*Banner)(nil)
15+
_ gnmiext.Defaultable = (*Banner)(nil)
1616
)
1717

1818
// Banner represents the pre-login banner configuration of the device.

internal/provider/cisco/nxos/bgp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
)
1515

1616
var (
17-
_ gnmiext.Configurable = (*BGP)(nil)
18-
_ gnmiext.Configurable = (*BGPDom)(nil)
17+
_ gnmiext.DataElement = (*BGP)(nil)
18+
_ gnmiext.DataElement = (*BGPDom)(nil)
1919
)
2020

2121
type BGP struct {

internal/provider/cisco/nxos/bgw.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/ironcore-dev/network-operator/internal/transport/gnmiext"
88
)
99

10-
var _ gnmiext.Configurable = (*MultisiteItems)(nil)
10+
var _ gnmiext.DataElement = (*MultisiteItems)(nil)
1111

1212
type MultisiteItems struct {
1313
SiteID string `json:"siteId"`

internal/provider/cisco/nxos/cert.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func (c *Certificate) EncodeKeyPair() (private, public []byte, err error) {
9191
}
9292

9393
var (
94-
_ gnmiext.Configurable = (*Trustpoint)(nil)
95-
_ gnmiext.Configurable = (*KeyPair)(nil)
94+
_ gnmiext.DataElement = (*Trustpoint)(nil)
95+
_ gnmiext.DataElement = (*KeyPair)(nil)
9696
)
9797

9898
// Trustpoint represents a PKI trustpoint configuration on a NX-OS device.

internal/provider/cisco/nxos/dhcprelay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/ironcore-dev/network-operator/internal/transport/gnmiext"
1010
)
1111

12-
var _ gnmiext.Configurable = (*DHCPRelayConfig)(nil)
12+
var _ gnmiext.DataElement = (*DHCPRelayConfig)(nil)
1313

1414
// DHCPRelayConfig represents the complete DHCP relay configuration tree.
1515
type DHCPRelayConfig struct {

internal/provider/cisco/nxos/dns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package nxos
55

66
import "github.com/ironcore-dev/network-operator/internal/transport/gnmiext"
77

8-
var _ gnmiext.Configurable = (*DNS)(nil)
8+
var _ gnmiext.DataElement = (*DNS)(nil)
99

1010
// DNS represents the DNS configuration on a NX-OS device.
1111
type DNS struct {

internal/provider/cisco/nxos/evi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/ironcore-dev/network-operator/internal/transport/gnmiext"
1515
)
1616

17-
var _ gnmiext.Configurable = (*BDEVI)(nil)
17+
var _ gnmiext.DataElement = (*BDEVI)(nil)
1818

1919
// BDEVI represents a Bridge Domain Ethernet VPN Instance (MAC-VRF).
2020
type BDEVI struct {

internal/provider/cisco/nxos/feat.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ package nxos
66
import "github.com/ironcore-dev/network-operator/internal/transport/gnmiext"
77

88
var (
9-
_ gnmiext.Configurable = (*Feature)(nil)
10-
_ gnmiext.Defaultable = (*Feature)(nil)
9+
_ gnmiext.DataElement = (*Feature)(nil)
10+
_ gnmiext.Defaultable = (*Feature)(nil)
1111
)
1212

1313
// Feature represents a dynamic feature configuration on a NX-OS device.

0 commit comments

Comments
 (0)