Make the lint cmd output a bit easier to follow

Have tried to give the output of the lint command a bit of a clean up to
try to make it easier to follow. This splits the output by chart, moves
the summary to the end of the report rather than at the top and fixes
the number of failed charts count.

Signed-off-by: Thomas O'Donnell <andy.tom@gmail.com>
pull/6310/head
Thomas O'Donnell 5 years ago
parent c19253d7cd
commit d911c4a2f5

@ -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))
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, "\t%s\n", err)
fmt.Fprintf(&message, "Error %s\n", err)
}
}
for _, msg := range result.Messages {
fmt.Fprintf(&message, "\t%s\n", msg)
fmt.Fprintf(&message, "%s\n", msg)
}
if len(result.Errors) > 0 {
return errors.New(message.String())
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