You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
726 B
32 lines
726 B
4 years ago
|
package accessctl
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
// FilterNot wraps another Filter. If that filter matches, FilterNot does not
|
||
|
// match, and vice-versa.
|
||
|
type FilterNot struct {
|
||
|
Filter Filter `yaml:"filter"`
|
||
|
}
|
||
|
|
||
|
var _ FilterInterface = FilterNot{}
|
||
|
|
||
|
// MatchCommit implements the method for FilterInterface.
|
||
|
func (f FilterNot) MatchCommit(req CommitRequest) error {
|
||
|
fI, err := f.Filter.Interface()
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("casting %+v to a FilterInterface: %w", f.Filter, err)
|
||
|
|
||
|
} else if err := fI.MatchCommit(req); errors.As(err, new(ErrFilterNoMatch)) {
|
||
|
return nil
|
||
|
} else if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return ErrFilterNoMatch{Err: errors.New("sub-filter did match")}
|
||
|
}
|
||
|
|
||
|
// TODO FilterAll
|
||
|
// TODO FilterAny
|