mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-01 04:21:36 +01:00
check rule conflict
Signed-off-by: Ziming Zhang <zziming@vmware.com> Change-Id: I95f7e683b30fa6059b5bb49a2fc8f78dd7276079
This commit is contained in:
parent
3b62addc76
commit
730d95edc8
@ -1,7 +1,6 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -242,12 +241,10 @@ func (r *RetentionAPI) checkRuleConflict(p *policy.Metadata) error {
|
|||||||
tid := rule.ID
|
tid := rule.ID
|
||||||
rule.ID = 0
|
rule.ID = 0
|
||||||
bs, _ := json.Marshal(rule)
|
bs, _ := json.Marshal(rule)
|
||||||
s := sha256.New()
|
if old, exists := temp[string(bs)]; exists {
|
||||||
h := s.Sum(bs)
|
|
||||||
if old, exists := temp[string(h)]; exists {
|
|
||||||
return fmt.Errorf("rule %d is conflict with rule %d", n, old)
|
return fmt.Errorf("rule %d is conflict with rule %d", n, old)
|
||||||
}
|
}
|
||||||
temp[string(h)] = tid
|
temp[string(bs)] = tid
|
||||||
rule.ID = tid
|
rule.ID = tid
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user