upsert acl on tag deletion

This commit is contained in:
abhishek9686 2024-09-28 17:20:17 +04:00
parent 9deac0ad2d
commit 5a7e1f3aff

View file

@ -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
}