Skip to content

Commit

Permalink
feat(models): add name field and getname method
Browse files Browse the repository at this point in the history
inspired by opiproject#279

Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Oct 24, 2023
1 parent 33e7614 commit 547704e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/models/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

// Bridge object, separate from protobuf for decoupling
type Bridge struct {
Name string
Vni uint32
VlanID uint32
VtepIP net.IPNet
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions pkg/models/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 6 additions & 0 deletions pkg/models/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (

// Port object, separate from protobuf for decoupling
type Port struct {
Name string
Ptype BridgePortType
MacAddress net.HardwareAddr
LogicalBridgeRefKeys []string
Expand Down Expand Up @@ -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
}
6 changes: 6 additions & 0 deletions pkg/models/svi.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

// Svi object, separate from protobuf for decoupling
type Svi struct {
Name string
VrfRefKey string
LogicalBridgeRefKey string
MacAddress net.HardwareAddr
Expand Down Expand Up @@ -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
}
6 changes: 6 additions & 0 deletions pkg/models/vrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit 547704e

Please sign in to comment.