mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-14 06:15:45 +00:00
Remove unused matcher
This commit is contained in:
parent
48b49a5cae
commit
bca3780b7f
@ -172,7 +172,7 @@ func (list ErrorList) PrefixIndex(index int) ErrorList {
|
|||||||
return list.Prefix(fmt.Sprintf("[%d]", index))
|
return list.Prefix(fmt.Sprintf("[%d]", index))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewValidationErrorFieldPrefixMatcher returns an errors.Matcher that returns true
|
// NewErrorTypeMatcher returns an errors.Matcher that returns true
|
||||||
// if the provided error is a Error and has the provided ErrorType.
|
// if the provided error is a Error and has the provided ErrorType.
|
||||||
func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher {
|
func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher {
|
||||||
return func(err error) bool {
|
return func(err error) bool {
|
||||||
@ -183,18 +183,6 @@ func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewValidationErrorFieldPrefixMatcher returns an errors.Matcher that returns true
|
|
||||||
// if the provided error is a Error and has a field with the provided
|
|
||||||
// prefix.
|
|
||||||
func NewValidationErrorFieldPrefixMatcher(prefix string) utilerrors.Matcher {
|
|
||||||
return func(err error) bool {
|
|
||||||
if e, ok := err.(*Error); ok {
|
|
||||||
return strings.HasPrefix(e.Field, prefix)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter removes items from the ErrorList that match the provided fns.
|
// Filter removes items from the ErrorList that match the provided fns.
|
||||||
func (list ErrorList) Filter(fns ...utilerrors.Matcher) ErrorList {
|
func (list ErrorList) Filter(fns ...utilerrors.Matcher) ErrorList {
|
||||||
err := utilerrors.FilterOut(utilerrors.NewAggregate(list), fns...)
|
err := utilerrors.FilterOut(utilerrors.NewAggregate(list), fns...)
|
||||||
|
@ -105,18 +105,6 @@ func TestErrListFilter(t *testing.T) {
|
|||||||
if len(list.Filter(NewErrorTypeMatcher(ErrorTypeInvalid))) != 1 {
|
if len(list.Filter(NewErrorTypeMatcher(ErrorTypeInvalid))) != 1 {
|
||||||
t.Errorf("should filter")
|
t.Errorf("should filter")
|
||||||
}
|
}
|
||||||
if len(list.Filter(NewValidationErrorFieldPrefixMatcher("test"))) != 1 {
|
|
||||||
t.Errorf("should filter")
|
|
||||||
}
|
|
||||||
if len(list.Filter(NewValidationErrorFieldPrefixMatcher("test."))) != 2 {
|
|
||||||
t.Errorf("should filter")
|
|
||||||
}
|
|
||||||
if len(list.Filter(NewValidationErrorFieldPrefixMatcher(""))) != 0 {
|
|
||||||
t.Errorf("should filter")
|
|
||||||
}
|
|
||||||
if len(list.Filter(NewValidationErrorFieldPrefixMatcher("field."), NewErrorTypeMatcher(ErrorTypeDuplicate))) != 1 {
|
|
||||||
t.Errorf("should filter")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestErrListPrefix(t *testing.T) {
|
func TestErrListPrefix(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user