Skip to content

Commit

Permalink
pass by pointer instead of by value
Browse files Browse the repository at this point in the history
  • Loading branch information
chdxD1 committed Sep 19, 2024
1 parent ecd86ad commit 789bcef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pkg/frr/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type templateConfig struct {
HostRouterID string
}

func (m *Manager) Configure(in Configuration, nm *nl.Manager, nwopCfg config.Config) (bool, error) {
func (m *Manager) Configure(in Configuration, nm *nl.Manager, nwopCfg *config.Config) (bool, error) {
// Remove permit from VRF and only allow deny rules for mgmt VRFs
for i := range in.VRFs {
if in.VRFs[i].Name != m.mgmtVrf {
Expand All @@ -51,7 +51,7 @@ func (m *Manager) Configure(in Configuration, nm *nl.Manager, nwopCfg config.Con
}
}

config, err := m.renderSubtemplates(in, nm)
frrConfig, err := m.renderSubtemplates(in, nm)
if err != nil {
return false, err
}
Expand All @@ -61,7 +61,7 @@ func (m *Manager) Configure(in Configuration, nm *nl.Manager, nwopCfg config.Con
return false, fmt.Errorf("error reading configuration file: %w", err)
}

targetConfig, err := render(m.configTemplate, config)
targetConfig, err := render(m.configTemplate, frrConfig)
if err != nil {
return false, err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/frr/frr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var _ = Describe("frr", func() {
It("return error if cannot get underlay IP", func() {
m := &Manager{}
nlMock.EXPECT().AddrList(gomock.Any(), gomock.Any()).Return(nil, errors.New("error listing addresses"))
_, err := m.Configure(Configuration{}, nl.NewManager(nlMock), config.Config{})
_, err := m.Configure(Configuration{}, nl.NewManager(nlMock), &config.Config{})
Expect(err).To(HaveOccurred())
})
It("return error if cannot node's name", func() {
Expand All @@ -148,7 +148,7 @@ var _ = Describe("frr", func() {
nlMock.EXPECT().AddrList(gomock.Any(), gomock.Any()).Return([]netlink.Addr{
{IPNet: netlink.NewIPNet(net.IPv4(0, 0, 0, 0))},
}, nil)
_, err := m.Configure(Configuration{}, nl.NewManager(nlMock), config.Config{})
_, err := m.Configure(Configuration{}, nl.NewManager(nlMock), &config.Config{})
Expect(err).To(HaveOccurred())

if isSet {
Expand All @@ -165,7 +165,7 @@ var _ = Describe("frr", func() {
nlMock.EXPECT().AddrList(gomock.Any(), gomock.Any()).Return([]netlink.Addr{
{IPNet: netlink.NewIPNet(net.IPv4(0, 0, 0, 0))},
}, nil)
_, err = m.Configure(Configuration{}, nl.NewManager(nlMock), config.Config{})
_, err = m.Configure(Configuration{}, nl.NewManager(nlMock), &config.Config{})
Expect(err).To(HaveOccurred())

if isSet {
Expand All @@ -189,7 +189,7 @@ var _ = Describe("frr", func() {
nlMock.EXPECT().AddrList(gomock.Any(), gomock.Any()).Return([]netlink.Addr{
{IPNet: netlink.NewIPNet(net.IPv4(0, 0, 0, 0))},
}, nil)
_, err = m.Configure(Configuration{}, nl.NewManager(nlMock), config.Config{})
_, err = m.Configure(Configuration{}, nl.NewManager(nlMock), &config.Config{})
Expect(err).To(HaveOccurred())

if isSet {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (r *reconcile) configureFRR(vrfConfigs []frr.VRFConfiguration, reloadTwice
changed, err := r.frrManager.Configure(frr.Configuration{
VRFs: vrfConfigs,
ASN: r.config.ServerASN,
}, r.netlinkManager, *r.config)
}, r.netlinkManager, r.config)
if err != nil {
r.Logger.Error(err, "error updating FRR configuration")
return fmt.Errorf("error updating FRR configuration: %w", err)
Expand Down

0 comments on commit 789bcef

Please sign in to comment.