mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-13 18:31:18 +01:00
Add network routers in account object
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
parent
f9be8f829e
commit
21586acc16
@ -278,7 +278,8 @@ type Account struct {
|
||||
// Settings is a dictionary of Account settings
|
||||
Settings *Settings `gorm:"embedded;embeddedPrefix:settings_"`
|
||||
|
||||
Networks []*networks.Network `gorm:"foreignKey:AccountID;references:id"`
|
||||
Networks []*networks.Network `gorm:"foreignKey:AccountID;references:id"`
|
||||
NetworkRouters []*networks.NetworkRouter `gorm:"foreignKey:AccountID;references:id"`
|
||||
}
|
||||
|
||||
// Subclass used in gorm to only load settings and not whole account
|
||||
@ -887,6 +888,11 @@ func (a *Account) Copy() *Account {
|
||||
nets = append(nets, network.Copy())
|
||||
}
|
||||
|
||||
networkRouters := []*networks.NetworkRouter{}
|
||||
for _, router := range a.NetworkRouters {
|
||||
networkRouters = append(networkRouters, router.Copy())
|
||||
}
|
||||
|
||||
return &Account{
|
||||
Id: a.Id,
|
||||
CreatedBy: a.CreatedBy,
|
||||
@ -906,6 +912,7 @@ func (a *Account) Copy() *Account {
|
||||
PostureChecks: postureChecks,
|
||||
Settings: settings,
|
||||
Networks: nets,
|
||||
NetworkRouters: networkRouters,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,3 +31,15 @@ func NewNetworkRouter(accountID string, networkID string, peer string, peerGroup
|
||||
Metric: metric,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (n *NetworkRouter) Copy() *NetworkRouter {
|
||||
return &NetworkRouter{
|
||||
ID: n.ID,
|
||||
NetworkID: n.NetworkID,
|
||||
AccountID: n.AccountID,
|
||||
Peer: n.Peer,
|
||||
PeerGroups: n.PeerGroups,
|
||||
Masquerade: n.Masquerade,
|
||||
Metric: n.Metric,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user