Skip to content

Commit

Permalink
Provide IsUnrecognizedConstraintError
Browse files Browse the repository at this point in the history
For decoupling frameworks and gatekeeper error handling
(which allows using go113 error conventinos in tests), I need to remove
the dependence of gatekeeper on error types defined in frameworks so
these may be changed safely to raw errors (where reasonable to do so).

As an intermediate, I'm adding this function so that gatekeeper can
continue to compile, and the implementation of this method may be
switched out in frameworks.

Signed-off-by: Will Beason <willbeason@google.com>
  • Loading branch information
Will Beason committed Nov 18, 2021
1 parent 8b4a99a commit 7700b8e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions constraint/pkg/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ func (e *UnrecognizedConstraintError) Error() string {
return fmt.Sprintf("Constraint kind %s is not recognized", e.s)
}

func IsUnrecognizedConstraintError(e error) bool {
_, ok := e.(*UnrecognizedConstraintError)
return ok
}

func NewUnrecognizedConstraintError(text string) error {
return &UnrecognizedConstraintError{text}
}
Expand Down

0 comments on commit 7700b8e

Please sign in to comment.