From 5a7e1f3aff8a707069f66adcddd59761996264bf Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Sat, 28 Sep 2024 17:20:17 +0400 Subject: [PATCH] upsert acl on tag deletion --- logic/acls.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/logic/acls.go b/logic/acls.go index 3372453d..0571adab 100644 --- a/logic/acls.go +++ b/logic/acls.go @@ -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 }