Skip to content

Commit

Permalink
Merge pull request #203 from ukinau/Support-Reason-Field-In-ForgetError
Browse files Browse the repository at this point in the history
Allow to put Reason in controller.ForgetError
  • Loading branch information
ibuildthecloud authored Oct 4, 2018
2 parents d675dc7 + b18da6e commit 8e5e5a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions condition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,16 @@ func (c Cond) ReasonAndMessageFromError(obj runtime.Object, err error) {
}
cond := findOrCreateCond(obj, string(c))
setValue(cond, "Message", err.Error())
if ce, ok := err.(*conditionError); ok {
switch ce := err.(type) {
case *conditionError:
setValue(cond, "Reason", ce.reason)
} else {
case *controller.ForgetError:
if ce.Reason != "" {
setValue(cond, "Reason", ce.Reason)
} else {
setValue(cond, "Reason", "Error")
}
default:
setValue(cond, "Reason", "Error")
}
}
Expand Down
3 changes: 2 additions & 1 deletion controller/error.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package controller

type ForgetError struct {
Err error
Err error
Reason string
}

func (f *ForgetError) Error() string {
Expand Down

0 comments on commit 8e5e5a6

Please sign in to comment.