Skip to content

Commit f8b1c64

Browse files
refactor: address Tim's comment
1 parent 1ee34c2 commit f8b1c64

File tree

2 files changed

+12
-32
lines changed

2 files changed

+12
-32
lines changed

cns/service/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,13 +1123,13 @@ type nodeNetworkConfigGetter interface {
11231123
Get(context.Context) (*v1alpha.NodeNetworkConfig, error)
11241124
}
11251125

1126-
type ipamStateReconciler interface {
1126+
type IpamStateReconciler interface {
11271127
ReconcileIPAMState(ncRequests []*cns.CreateNetworkContainerRequest, podInfoByIP map[string]cns.PodInfo, nnc *v1alpha.NodeNetworkConfig) cnstypes.ResponseCode
11281128
}
11291129

11301130
// TODO(rbtr) where should this live??
11311131
// reconcileInitialCNSState initializes cns by passing pods and a CreateNetworkContainerRequest
1132-
func reconcileInitialCNSState(ctx context.Context, cli nodeNetworkConfigGetter, ipamReconciler ipamStateReconciler, podInfoByIPProvider cns.PodInfoByIPProvider) error {
1132+
func reconcileInitialCNSState(ctx context.Context, cli nodeNetworkConfigGetter, ipamReconciler IpamStateReconciler, podInfoByIPProvider cns.PodInfoByIPProvider) error {
11331133
// Get nnc using direct client
11341134
nnc, err := cli.Get(ctx)
11351135
if err != nil {

nmagent/equality.go

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
package nmagent
22

3-
// equalPtr compares two Interfaces objects for equality.
4-
func (i *Interfaces) equalPtr(other *Interfaces) bool {
3+
// Equal compares two Interfaces objects for equality.
4+
func (i Interfaces) Equal(other Interfaces) bool {
55
if len(i.Entries) != len(other.Entries) {
66
return false
77
}
88
for idx, entry := range i.Entries {
9-
if !entry.equalPtr(&other.Entries[idx]) {
9+
if !entry.Equal(other.Entries[idx]) {
1010
return false
1111
}
1212
}
1313
return true
1414
}
1515

16-
// Equal compares two Interfaces objects for equality.
17-
func (i Interfaces) Equal(other Interfaces) bool {
18-
return i.equalPtr(&other)
19-
}
20-
21-
// equalPtr compares two Interface objects for equality.
22-
func (i *Interface) equalPtr(other *Interface) bool {
16+
// Equal compares two Interface objects for equality.
17+
func (i Interface) Equal(other Interface) bool {
2318
if len(i.InterfaceSubnets) != len(other.InterfaceSubnets) {
2419
return false
2520
}
2621
for idx, subnet := range i.InterfaceSubnets {
27-
if !subnet.equalPtr(&other.InterfaceSubnets[idx]) {
22+
if !subnet.Equal(other.InterfaceSubnets[idx]) {
2823
return false
2924
}
3025
}
@@ -34,38 +29,23 @@ func (i *Interface) equalPtr(other *Interface) bool {
3429
return true
3530
}
3631

37-
// Equal compares two Interface objects for equality.
38-
func (i Interface) Equal(other Interface) bool {
39-
return i.equalPtr(&other)
40-
}
41-
42-
// equalPtr compares two InterfaceSubnet objects for equality.
43-
func (s *InterfaceSubnet) equalPtr(other *InterfaceSubnet) bool {
32+
// Equal compares two InterfaceSubnet objects for equality.
33+
func (s InterfaceSubnet) Equal(other InterfaceSubnet) bool {
4434
if len(s.IPAddress) != len(other.IPAddress) {
4535
return false
4636
}
4737
if s.Prefix != other.Prefix {
4838
return false
4939
}
5040
for idx, ip := range s.IPAddress {
51-
if !ip.equalPtr(&other.IPAddress[idx]) {
41+
if !ip.Equal(other.IPAddress[idx]) {
5242
return false
5343
}
5444
}
5545
return true
5646
}
5747

58-
// Equal compares two InterfaceSubnet objects for equality.
59-
func (s InterfaceSubnet) Equal(other InterfaceSubnet) bool {
60-
return s.equalPtr(&other)
61-
}
62-
63-
// equalPtr compares two NodeIP objects for equality.
64-
func (ip *NodeIP) equalPtr(other *NodeIP) bool {
65-
return ip.IsPrimary == other.IsPrimary && ip.Address.Equal(other.Address)
66-
}
67-
6848
// Equal compares two NodeIP objects for equality.
6949
func (ip NodeIP) Equal(other NodeIP) bool {
70-
return ip.equalPtr(&other)
50+
return ip.IsPrimary == other.IsPrimary && ip.Address.Equal(other.Address)
7151
}

0 commit comments

Comments
 (0)