mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-11 07:34:31 +08:00
upsert acl on tag deletion
This commit is contained in:
parent
9deac0ad2d
commit
5a7e1f3aff
1 changed files with 6 additions and 0 deletions
|
@ -415,11 +415,13 @@ func UpdateDeviceTag(OldID, newID models.TagID, netID models.NetworkID) {
|
|||
|
||||
func RemoveDeviceTagFromAclPolicies(tagID models.TagID, netID models.NetworkID) error {
|
||||
acls := listDevicePolicies(netID)
|
||||
update := false
|
||||
for _, acl := range acls {
|
||||
for i, srcTagI := range acl.Src {
|
||||
if srcTagI.ID == models.DeviceAclID {
|
||||
if tagID.String() == srcTagI.Value {
|
||||
acl.Src = append(acl.Src[:i], acl.Src[i+1:]...)
|
||||
update = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -427,9 +429,13 @@ func RemoveDeviceTagFromAclPolicies(tagID models.TagID, netID models.NetworkID)
|
|||
if dstTagI.ID == models.DeviceAclID {
|
||||
if tagID.String() == dstTagI.Value {
|
||||
acl.Dst = append(acl.Dst[:i], acl.Dst[i+1:]...)
|
||||
update = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if update {
|
||||
UpsertAcl(acl)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue