Merge pull request #6310 from andytom/feat/improve_linting_ux

Make the lint cmd output a bit easier to follow
pull/6362/head
Taylor Thomas 5 years ago committed by GitHub
commit 347fd8c5c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -56,20 +56,47 @@ func newLintCmd(out io.Writer) *cobra.Command {
if err != nil {
return err
}
result := client.Run(paths, vals)
var message strings.Builder
fmt.Fprintf(&message, "%d chart(s) linted, %d chart(s) failed\n", result.TotalChartsLinted, len(result.Errors))
for _, err := range result.Errors {
fmt.Fprintf(&message, "\t%s\n", err)
}
for _, msg := range result.Messages {
fmt.Fprintf(&message, "\t%s\n", msg)
}
failed := 0
for _, path := range paths {
fmt.Fprintf(&message, "==> Linting %s\n", path)
result := client.Run([]string{path}, vals)
// All the Errors that are generated by a chart
// that failed a lint will be included in the
// results.Messages so we only need to print
// the Errors if there are no Messages.
if len(result.Messages) == 0 {
for _, err := range result.Errors {
fmt.Fprintf(&message, "Error %s\n", err)
}
}
if len(result.Errors) > 0 {
return errors.New(message.String())
for _, msg := range result.Messages {
fmt.Fprintf(&message, "%s\n", msg)
}
if len(result.Errors) != 0 {
failed++
}
// Adding extra new line here to break up the
// results, stops this from being a big wall of
// text and makes it easier to follow.
fmt.Fprint(&message, "\n")
}
fmt.Fprintf(out, message.String())
var summary strings.Builder
fmt.Fprintf(&summary, "%d chart(s) linted, %d chart(s) failed", len(paths), failed)
if failed > 0 {
return errors.New(summary.String())
}
fmt.Fprintf(out, "%s\n", summary.String())
return nil
},
}

Loading…
Cancel
Save