Przeglądaj źródła

upsert acl on tag deletion

abhishek9686 11 miesięcy temu
rodzic
commit
5a7e1f3aff
1 zmienionych plików z 6 dodań i 0 usunięć
  1. 6 0
      logic/acls.go

+ 6 - 0
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
 }