|
|
|
@ -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
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|