mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-14 19:00:50 +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 is a dictionary of Account settings
|
||||||
Settings *Settings `gorm:"embedded;embeddedPrefix: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
|
// 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())
|
nets = append(nets, network.Copy())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
networkRouters := []*networks.NetworkRouter{}
|
||||||
|
for _, router := range a.NetworkRouters {
|
||||||
|
networkRouters = append(networkRouters, router.Copy())
|
||||||
|
}
|
||||||
|
|
||||||
return &Account{
|
return &Account{
|
||||||
Id: a.Id,
|
Id: a.Id,
|
||||||
CreatedBy: a.CreatedBy,
|
CreatedBy: a.CreatedBy,
|
||||||
@ -906,6 +912,7 @@ func (a *Account) Copy() *Account {
|
|||||||
PostureChecks: postureChecks,
|
PostureChecks: postureChecks,
|
||||||
Settings: settings,
|
Settings: settings,
|
||||||
Networks: nets,
|
Networks: nets,
|
||||||
|
NetworkRouters: networkRouters,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,3 +31,15 @@ func NewNetworkRouter(accountID string, networkID string, peer string, peerGroup
|
|||||||
Metric: metric,
|
Metric: metric,
|
||||||
}, nil
|
}, 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