From 789bcef00df081251078656dd531c5c27170ea09 Mon Sep 17 00:00:00 2001 From: Christopher Dziomba Date: Thu, 19 Sep 2024 17:15:39 +0200 Subject: [PATCH] pass by pointer instead of by value --- pkg/frr/configure.go | 6 +++--- pkg/frr/frr_test.go | 8 ++++---- pkg/reconciler/layer3.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/frr/configure.go b/pkg/frr/configure.go index 00132e8..870304e 100644 --- a/pkg/frr/configure.go +++ b/pkg/frr/configure.go @@ -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 { @@ -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 } @@ -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 } diff --git a/pkg/frr/frr_test.go b/pkg/frr/frr_test.go index b1c6f0a..f04eb7b 100644 --- a/pkg/frr/frr_test.go +++ b/pkg/frr/frr_test.go @@ -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() { @@ -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 { @@ -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 { @@ -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 { diff --git a/pkg/reconciler/layer3.go b/pkg/reconciler/layer3.go index 9b52603..f66e91d 100644 --- a/pkg/reconciler/layer3.go +++ b/pkg/reconciler/layer3.go @@ -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)