feat(aa): rule interface: replace less & equal by the compare method.
- set a new alphabet order to sort AARE based string. - unify compare function for all rules - handle some special sort order, eg: base include
This commit is contained in:
parent
747292e954
commit
4cbacc186c
22 changed files with 250 additions and 399 deletions
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
package aa
|
||||
|
||||
import "fmt"
|
||||
|
||||
const USERNS Kind = "userns"
|
||||
|
||||
type Userns struct {
|
||||
|
|
@ -24,17 +26,12 @@ func (r *Userns) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Userns) Less(other any) bool {
|
||||
func (r *Userns) Compare(other Rule) int {
|
||||
o, _ := other.(*Userns)
|
||||
if r.Create != o.Create {
|
||||
return r.Create
|
||||
if res := compare(r.Create, o.Create); res != 0 {
|
||||
return res
|
||||
}
|
||||
return r.Qualifier.Less(o.Qualifier)
|
||||
}
|
||||
|
||||
func (r *Userns) Equals(other any) bool {
|
||||
o, _ := other.(*Userns)
|
||||
return r.Create == o.Create && r.Qualifier.Equals(o.Qualifier)
|
||||
return r.Qualifier.Compare(o.Qualifier)
|
||||
}
|
||||
|
||||
func (r *Userns) String() string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue