Skip to content

Commit 8fef722

Browse files
committed
Code cleanup and refactoring
Signed-off-by: PingWang <[email protected]>
1 parent d9f3e96 commit 8fef722

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

cmd/kubeadm/app/preflight/checks.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.String
10701070
Name string
10711071
Errors []error
10721072
}
1073-
found := []checkErrors{}
1073+
var errsBuffer bytes.Buffer
10741074

10751075
for _, c := range checks {
10761076
name := c.Name()
@@ -1085,18 +1085,12 @@ func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.String
10851085
for _, w := range warnings {
10861086
io.WriteString(ww, fmt.Sprintf("\t[WARNING %s]: %v\n", name, w))
10871087
}
1088-
if len(errs) > 0 {
1089-
found = append(found, checkErrors{Name: name, Errors: errs})
1088+
for _, i := range errs {
1089+
errsBuffer.WriteString(fmt.Sprintf("\t[ERROR %s]: %v\n", name, i.Error()))
10901090
}
10911091
}
1092-
if len(found) > 0 {
1093-
var errs bytes.Buffer
1094-
for _, c := range found {
1095-
for _, i := range c.Errors {
1096-
errs.WriteString(fmt.Sprintf("\t[ERROR %s]: %v\n", c.Name, i.Error()))
1097-
}
1098-
}
1099-
return &Error{Msg: errs.String()}
1092+
if errsBuffer.Len() > 0 {
1093+
return &Error{Msg: errsBuffer.String()}
11001094
}
11011095
return nil
11021096
}

0 commit comments

Comments
 (0)