mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-20 01:06:45 +00:00
[management] Remove resource from groups when resource deleted (#3059)
This commit is contained in:
@@ -569,10 +569,29 @@ func (a *Account) DeletePeer(peerID string) {
|
||||
}
|
||||
}
|
||||
|
||||
for i, r := range a.NetworkRouters {
|
||||
if r.Peer == peerID {
|
||||
a.NetworkRouters = append(a.NetworkRouters[:i], a.NetworkRouters[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
delete(a.Peers, peerID)
|
||||
a.Network.IncSerial()
|
||||
}
|
||||
|
||||
func (a *Account) DeleteResource(resourceID string) {
|
||||
// delete resource from groups
|
||||
for _, g := range a.Groups {
|
||||
for i, pk := range g.Resources {
|
||||
if pk.ID == resourceID {
|
||||
g.Resources = append(g.Resources[:i], g.Resources[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FindPeerByPubKey looks for a Peer by provided WireGuard public key in the Account or returns error if it wasn't found.
|
||||
// It will return an object copy of the peer.
|
||||
func (a *Account) FindPeerByPubKey(peerPubKey string) (*nbpeer.Peer, error) {
|
||||
|
||||
Reference in New Issue
Block a user