Code cleanup and refactoring

Signed-off-by: PingWang <wang.ping5@zte.com.cn>
pull/564/head
PingWang 2019-02-22 16:48:00 +08:00
parent d9f3e96796
commit 8fef7221a1
1 changed files with 5 additions and 11 deletions

View File

@ -1070,7 +1070,7 @@ func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.String
Name string Name string
Errors []error Errors []error
} }
found := []checkErrors{} var errsBuffer bytes.Buffer
for _, c := range checks { for _, c := range checks {
name := c.Name() name := c.Name()
@ -1085,18 +1085,12 @@ func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.String
for _, w := range warnings { for _, w := range warnings {
io.WriteString(ww, fmt.Sprintf("\t[WARNING %s]: %v\n", name, w)) io.WriteString(ww, fmt.Sprintf("\t[WARNING %s]: %v\n", name, w))
} }
if len(errs) > 0 { for _, i := range errs {
found = append(found, checkErrors{Name: name, Errors: errs}) errsBuffer.WriteString(fmt.Sprintf("\t[ERROR %s]: %v\n", name, i.Error()))
} }
} }
if len(found) > 0 { if errsBuffer.Len() > 0 {
var errs bytes.Buffer return &Error{Msg: errsBuffer.String()}
for _, c := range found {
for _, i := range c.Errors {
errs.WriteString(fmt.Sprintf("\t[ERROR %s]: %v\n", c.Name, i.Error()))
}
}
return &Error{Msg: errs.String()}
} }
return nil return nil
} }