|
@@ -105,10 +105,6 @@ type AllocationFilter interface {
|
|
|
// Equals returns true if the two AllocationFilters are logically
|
|
// Equals returns true if the two AllocationFilters are logically
|
|
|
// equivalent.
|
|
// equivalent.
|
|
|
Equals(AllocationFilter) bool
|
|
Equals(AllocationFilter) bool
|
|
|
-
|
|
|
|
|
- // empty returns true if the filter isn't filtering anything, i.e. the
|
|
|
|
|
- // filter is a no-op.
|
|
|
|
|
- empty() bool
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// AllocationFilterCondition is the lowest-level type of filter. It represents
|
|
// AllocationFilterCondition is the lowest-level type of filter. It represents
|
|
@@ -150,10 +146,6 @@ func (left AllocationFilterCondition) Equals(right AllocationFilter) bool {
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (filter AllocationFilterCondition) empty() bool {
|
|
|
|
|
- return false
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// AllocationFilterOr is a set of filters that should be evaluated as a logical
|
|
// AllocationFilterOr is a set of filters that should be evaluated as a logical
|
|
|
// OR.
|
|
// OR.
|
|
|
type AllocationFilterOr struct {
|
|
type AllocationFilterOr struct {
|
|
@@ -223,10 +215,7 @@ func (filter AllocationFilterOr) sort() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (left AllocationFilterOr) Equals(right AllocationFilter) bool {
|
|
func (left AllocationFilterOr) Equals(right AllocationFilter) bool {
|
|
|
- if left.empty() {
|
|
|
|
|
- return right == nil || right.empty()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // The type cast takes care of right == nil as well
|
|
|
rightOr, ok := right.(AllocationFilterOr)
|
|
rightOr, ok := right.(AllocationFilterOr)
|
|
|
if !ok {
|
|
if !ok {
|
|
|
return false
|
|
return false
|
|
@@ -239,18 +228,6 @@ func (left AllocationFilterOr) Equals(right AllocationFilter) bool {
|
|
|
return left.String() == rightOr.String()
|
|
return left.String() == rightOr.String()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (filter AllocationFilterOr) empty() bool {
|
|
|
|
|
- for _, inner := range filter.Filters {
|
|
|
|
|
- if inner == nil {
|
|
|
|
|
- continue
|
|
|
|
|
- }
|
|
|
|
|
- if !inner.empty() {
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return true
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// AllocationFilterOr is a set of filters that should be evaluated as a logical
|
|
// AllocationFilterOr is a set of filters that should be evaluated as a logical
|
|
|
// AND.
|
|
// AND.
|
|
|
type AllocationFilterAnd struct {
|
|
type AllocationFilterAnd struct {
|
|
@@ -304,10 +281,7 @@ func (filter AllocationFilterAnd) sort() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (left AllocationFilterAnd) Equals(right AllocationFilter) bool {
|
|
func (left AllocationFilterAnd) Equals(right AllocationFilter) bool {
|
|
|
- if left.empty() {
|
|
|
|
|
- return right == nil || right.empty()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // The type cast takes care of right == nil as well
|
|
|
rightAnd, ok := right.(AllocationFilterAnd)
|
|
rightAnd, ok := right.(AllocationFilterAnd)
|
|
|
if !ok {
|
|
if !ok {
|
|
|
return false
|
|
return false
|
|
@@ -320,18 +294,6 @@ func (left AllocationFilterAnd) Equals(right AllocationFilter) bool {
|
|
|
return left.String() == rightAnd.String()
|
|
return left.String() == rightAnd.String()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (filter AllocationFilterAnd) empty() bool {
|
|
|
|
|
- for _, inner := range filter.Filters {
|
|
|
|
|
- if inner == nil {
|
|
|
|
|
- continue
|
|
|
|
|
- }
|
|
|
|
|
- if !inner.empty() {
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return true
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
func (filter AllocationFilterCondition) Matches(a *Allocation) bool {
|
|
func (filter AllocationFilterCondition) Matches(a *Allocation) bool {
|
|
|
if a == nil {
|
|
if a == nil {
|
|
|
return false
|
|
return false
|
|
@@ -544,7 +506,3 @@ func (left AllocationFilterNone) Equals(right AllocationFilter) bool {
|
|
|
_, ok := right.(AllocationFilterNone)
|
|
_, ok := right.(AllocationFilterNone)
|
|
|
return ok
|
|
return ok
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-func (afn AllocationFilterNone) empty() bool {
|
|
|
|
|
- return false
|
|
|
|
|
-}
|
|
|