Make struct members private, alter formatting, add unwrap method

Signed-off-by: Jack Andersen <jandersen@plaid.com>
This commit is contained in:
Jack Andersen 2022-12-10 11:33:58 -08:00
parent 66fe8e8118
commit 89dfafefe7
No known key found for this signature in database
GPG Key ID: 3F47FBCA70B709C7
1 changed files with 9 additions and 5 deletions

View File

@ -46,12 +46,16 @@ const rollingUpdateTaintKey = "kops.k8s.io/scheduled-for-update"
// ValidationTimeoutError represents an error that occurs when // ValidationTimeoutError represents an error that occurs when
// the cluster fails to validate within the designated timeout. // the cluster fails to validate within the designated timeout.
type ValidationTimeoutError struct { type ValidationTimeoutError struct {
Operation string operation string
Err error err error
} }
func (v *ValidationTimeoutError) Error() string { func (v *ValidationTimeoutError) Error() string {
return fmt.Sprintf("error validating cluster%s: %v", v.Operation, v.Err) return fmt.Sprintf("error validating cluster%s: %s", v.operation, v.err.Error())
}
func (v *ValidationTimeoutError) Unwrap() error {
return v.err
} }
// Is checks that a given error is a ValidationTimeoutError. // Is checks that a given error is a ValidationTimeoutError.
@ -501,8 +505,8 @@ func (c *RollingUpdateCluster) maybeValidate(operation string, validateCount int
if c.FailOnValidate { if c.FailOnValidate {
klog.Errorf("Cluster did not validate within %s", c.ValidationTimeout) klog.Errorf("Cluster did not validate within %s", c.ValidationTimeout)
return &ValidationTimeoutError{ return &ValidationTimeoutError{
Operation: operation, operation: operation,
Err: err, err: err,
} }
} }