forked from goharbor/harbor-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unrecoverrable.go
51 lines (43 loc) · 951 Bytes
/
unrecoverrable.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package errors
import (
"github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
"sigs.k8s.io/kustomize/kstatus/status"
)
const (
OperatorReason = "operatorError"
InvalidSpecReason = "invalidSpec"
)
type unrecoverrableError struct {
cause error
reason string
message string
}
func UnrecoverrableError(err error, reason, message string) error {
return &unrecoverrableError{
cause: err,
reason: reason,
message: message,
}
}
func (err *unrecoverrableError) Error() string {
return errors.Wrap(err.cause, err.message).Error()
}
func (err *unrecoverrableError) Status() []status.Condition {
return []status.Condition{
{
Type: status.ConditionInProgress,
Message: "",
Reason: "",
Status: v1.ConditionFalse,
}, {
Type: status.ConditionFailed,
Message: err.cause.Error(),
Reason: err.reason,
Status: v1.ConditionTrue,
},
}
}
func (err *unrecoverrableError) Cause() error {
return err.cause
}