mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-22 08:03:30 +01:00
prevent duplicate rules during updates
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
parent
df98c67ac8
commit
b60e2c3261
@ -128,7 +128,7 @@ func (h *Policies) savePolicy(w http.ResponseWriter, r *http.Request, accountID
|
|||||||
Description: req.Description,
|
Description: req.Description,
|
||||||
}
|
}
|
||||||
for _, rule := range req.Rules {
|
for _, rule := range req.Rules {
|
||||||
ruleID := policyID // TODO: when policy can contain multiple rules, need refactor
|
var ruleID string
|
||||||
if rule.Id != nil {
|
if rule.Id != nil {
|
||||||
ruleID = *rule.Id
|
ruleID = *rule.Id
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ func validatePolicy(ctx context.Context, transaction Store, accountID string, po
|
|||||||
for i, rule := range policy.Rules {
|
for i, rule := range policy.Rules {
|
||||||
ruleCopy := rule.Copy()
|
ruleCopy := rule.Copy()
|
||||||
if ruleCopy.ID == "" {
|
if ruleCopy.ID == "" {
|
||||||
ruleCopy.ID = xid.New().String()
|
ruleCopy.ID = policy.ID // TODO: when policy can contain multiple rules, need refactor
|
||||||
ruleCopy.PolicyID = policy.ID
|
ruleCopy.PolicyID = policy.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user