From 547704e12f92994b4c6c5e2ec365766a8a48cc85 Mon Sep 17 00:00:00 2001 From: Boris Glimcher Date: Tue, 24 Oct 2023 04:21:54 +0300 Subject: [PATCH] feat(models): add name field and getname method inspired by #279 Signed-off-by: Boris Glimcher --- pkg/models/bridge.go | 6 ++++++ pkg/models/interface.go | 1 + pkg/models/port.go | 6 ++++++ pkg/models/svi.go | 6 ++++++ pkg/models/vrf.go | 6 ++++++ 5 files changed, 25 insertions(+) diff --git a/pkg/models/bridge.go b/pkg/models/bridge.go index 0e4e8ba0..42af18c8 100644 --- a/pkg/models/bridge.go +++ b/pkg/models/bridge.go @@ -13,6 +13,7 @@ import ( // Bridge object, separate from protobuf for decoupling type Bridge struct { + Name string Vni uint32 VlanID uint32 VtepIP net.IPNet @@ -44,3 +45,8 @@ func (in *Bridge) ToPb() (*pb.LogicalBridge, error) { // TODO: add VtepIpPrefix return bridge, nil } + +// GetName returns object unique name +func (in *Bridge) GetName() string { + return in.Name +} diff --git a/pkg/models/interface.go b/pkg/models/interface.go index a57daa1e..fb06bba8 100644 --- a/pkg/models/interface.go +++ b/pkg/models/interface.go @@ -7,4 +7,5 @@ package models // EvpnObject is an interface for all domain objects in evpn-gw type EvpnObject[T any] interface { ToPb() (T, error) + GetName() string } diff --git a/pkg/models/port.go b/pkg/models/port.go index 03cc42e8..d95f2be6 100644 --- a/pkg/models/port.go +++ b/pkg/models/port.go @@ -24,6 +24,7 @@ const ( // Port object, separate from protobuf for decoupling type Port struct { + Name string Ptype BridgePortType MacAddress net.HardwareAddr LogicalBridgeRefKeys []string @@ -53,3 +54,8 @@ func (in *Port) ToPb() (*pb.BridgePort, error) { // TODO: add VtepIpPrefix return port, nil } + +// GetName returns object unique name +func (in *Port) GetName() string { + return in.Name +} diff --git a/pkg/models/svi.go b/pkg/models/svi.go index 9abbd5bd..7fe53103 100644 --- a/pkg/models/svi.go +++ b/pkg/models/svi.go @@ -13,6 +13,7 @@ import ( // Svi object, separate from protobuf for decoupling type Svi struct { + Name string VrfRefKey string LogicalBridgeRefKey string MacAddress net.HardwareAddr @@ -62,3 +63,8 @@ func (in *Svi) ToPb() (*pb.Svi, error) { // TODO: add GwIpPrefix return svi, nil } + +// GetName returns object unique name +func (in *Svi) GetName() string { + return in.Name +} diff --git a/pkg/models/vrf.go b/pkg/models/vrf.go index 72a797f2..98e0170d 100644 --- a/pkg/models/vrf.go +++ b/pkg/models/vrf.go @@ -13,6 +13,7 @@ import ( // Vrf object, separate from protobuf for decoupling type Vrf struct { + Name string Vni uint32 LoopbackIP net.IPNet VtepIP net.IPNet @@ -49,3 +50,8 @@ func (in *Vrf) ToPb() (*pb.Vrf, error) { // TODO: add LocalAs, LoopbackIP, VtepIP return vrf, nil } + +// GetName returns object unique name +func (in *Vrf) GetName() string { + return in.Name +}