impl 'IsWait' functions

Co-authored-by: Alex Wang <453102040@qq.com>
This commit is contained in:
shinta
2022-04-14 16:06:37 +09:00
parent 621c4aa599
commit 22984402ab
4 changed files with 25 additions and 4 deletions

View File

@@ -193,16 +193,21 @@ func (s *Status) IsSuccess() bool {
return s.Code() == Success
}
// IsWait returns true if and only if "Status" is non-nil and its Code is "Wait".
func (s *Status) IsWait() bool {
return s.Code() == Wait
}
// IsUnschedulable returns true if "Status" is Unschedulable (Unschedulable or UnschedulableAndUnresolvable).
func (s *Status) IsUnschedulable() bool {
code := s.Code()
return code == Unschedulable || code == UnschedulableAndUnresolvable
}
// AsError returns nil if the status is a success; otherwise returns an "error" object
// AsError returns nil if the status is a success or a wait; otherwise returns an "error" object
// with a concatenated message on reasons of the Status.
func (s *Status) AsError() error {
if s.IsSuccess() {
if s.IsSuccess() || s.IsWait() {
return nil
}
if s.err != nil {