|
|
@ -29,6 +29,7 @@ import (
|
|
|
|
"helm.sh/helm/v3/pkg/action"
|
|
|
|
"helm.sh/helm/v3/pkg/action"
|
|
|
|
"helm.sh/helm/v3/pkg/cli/values"
|
|
|
|
"helm.sh/helm/v3/pkg/cli/values"
|
|
|
|
"helm.sh/helm/v3/pkg/getter"
|
|
|
|
"helm.sh/helm/v3/pkg/getter"
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/lint/support"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var longLintHelp = `
|
|
|
|
var longLintHelp = `
|
|
|
@ -76,12 +77,23 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
|
|
|
|
|
|
|
|
var message strings.Builder
|
|
|
|
var message strings.Builder
|
|
|
|
failed := 0
|
|
|
|
failed := 0
|
|
|
|
|
|
|
|
errorsOrWarnings := 0
|
|
|
|
|
|
|
|
|
|
|
|
for _, path := range paths {
|
|
|
|
for _, path := range paths {
|
|
|
|
fmt.Fprintf(&message, "==> Linting %s\n", path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result := client.Run([]string{path}, vals)
|
|
|
|
result := client.Run([]string{path}, vals)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If there is no errors/warnings and quiet flag is set
|
|
|
|
|
|
|
|
// go to the next chart
|
|
|
|
|
|
|
|
hasWarningsOrErrors := action.HasWarningsOrErrors(result)
|
|
|
|
|
|
|
|
if hasWarningsOrErrors {
|
|
|
|
|
|
|
|
errorsOrWarnings++
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if client.Quiet && !hasWarningsOrErrors {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintf(&message, "==> Linting %s\n", path)
|
|
|
|
|
|
|
|
|
|
|
|
// All the Errors that are generated by a chart
|
|
|
|
// All the Errors that are generated by a chart
|
|
|
|
// that failed a lint will be included in the
|
|
|
|
// that failed a lint will be included in the
|
|
|
|
// results.Messages so we only need to print
|
|
|
|
// results.Messages so we only need to print
|
|
|
@ -93,7 +105,9 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, msg := range result.Messages {
|
|
|
|
for _, msg := range result.Messages {
|
|
|
|
fmt.Fprintf(&message, "%s\n", msg)
|
|
|
|
if !client.Quiet || msg.Severity > support.InfoSev {
|
|
|
|
|
|
|
|
fmt.Fprintf(&message, "%s\n", msg)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(result.Errors) != 0 {
|
|
|
|
if len(result.Errors) != 0 {
|
|
|
@ -112,7 +126,9 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
if failed > 0 {
|
|
|
|
if failed > 0 {
|
|
|
|
return errors.New(summary)
|
|
|
|
return errors.New(summary)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Fprintln(out, summary)
|
|
|
|
if !client.Quiet || errorsOrWarnings > 0 {
|
|
|
|
|
|
|
|
fmt.Fprintln(out, summary)
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -120,6 +136,7 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
f := cmd.Flags()
|
|
|
|
f := cmd.Flags()
|
|
|
|
f.BoolVar(&client.Strict, "strict", false, "fail on lint warnings")
|
|
|
|
f.BoolVar(&client.Strict, "strict", false, "fail on lint warnings")
|
|
|
|
f.BoolVar(&client.WithSubcharts, "with-subcharts", false, "lint dependent charts")
|
|
|
|
f.BoolVar(&client.WithSubcharts, "with-subcharts", false, "lint dependent charts")
|
|
|
|
|
|
|
|
f.BoolVar(&client.Quiet, "quiet", false, "print only warnings and errors")
|
|
|
|
addValueOptionsFlags(f, valueOpts)
|
|
|
|
addValueOptionsFlags(f, valueOpts)
|
|
|
|
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
return cmd
|
|
|
|