|
|
@ -31,6 +31,7 @@ import (
|
|
|
|
"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"
|
|
|
|
"helm.sh/helm/v3/pkg/lint/support"
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/lint/rules"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var longLintHelp = `
|
|
|
|
var longLintHelp = `
|
|
|
@ -46,6 +47,7 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
client := action.NewLint()
|
|
|
|
client := action.NewLint()
|
|
|
|
valueOpts := &values.Options{}
|
|
|
|
valueOpts := &values.Options{}
|
|
|
|
var kubeVersion string
|
|
|
|
var kubeVersion string
|
|
|
|
|
|
|
|
var lintIgnoreFile string
|
|
|
|
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "lint PATH",
|
|
|
|
Use: "lint PATH",
|
|
|
@ -86,15 +88,25 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ignorePatterns []string
|
|
|
|
|
|
|
|
if lintIgnoreFile != "" {
|
|
|
|
|
|
|
|
ignorePatterns, err = rules.ParseIgnoreFile(lintIgnoreFile)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return fmt.Errorf("failed to parse .helmlintignore file: %v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var message strings.Builder
|
|
|
|
var message strings.Builder
|
|
|
|
failed := 0
|
|
|
|
failed := 0
|
|
|
|
errorsOrWarnings := 0
|
|
|
|
errorsOrWarnings := 0
|
|
|
|
|
|
|
|
|
|
|
|
for _, path := range paths {
|
|
|
|
for _, path := range paths {
|
|
|
|
|
|
|
|
if rules.IsIgnored(path, ignorePatterns) {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
hasWarningsOrErrors := action.HasWarningsOrErrors(result)
|
|
|
|
if hasWarningsOrErrors {
|
|
|
|
if hasWarningsOrErrors {
|
|
|
|
errorsOrWarnings++
|
|
|
|
errorsOrWarnings++
|
|
|
@ -105,10 +117,6 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintf(&message, "==> Linting %s\n", path)
|
|
|
|
fmt.Fprintf(&message, "==> Linting %s\n", path)
|
|
|
|
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
if len(result.Messages) == 0 {
|
|
|
|
for _, err := range result.Errors {
|
|
|
|
for _, err := range result.Errors {
|
|
|
|
fmt.Fprintf(&message, "Error %s\n", err)
|
|
|
|
fmt.Fprintf(&message, "Error %s\n", err)
|
|
|
@ -125,9 +133,6 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
failed++
|
|
|
|
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.Fprint(&message, "\n")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -149,7 +154,10 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|
|
|
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")
|
|
|
|
f.BoolVar(&client.Quiet, "quiet", false, "print only warnings and errors")
|
|
|
|
f.StringVar(&kubeVersion, "kube-version", "", "Kubernetes version used for capabilities and deprecation checks")
|
|
|
|
f.StringVar(&kubeVersion, "kube-version", "", "Kubernetes version used for capabilities and deprecation checks")
|
|
|
|
|
|
|
|
f.StringVar(&lintIgnoreFile, "lint-ignore-file", "", "path to .helmlintignore file to specify ignore patterns") // Add the flag for .helmlintignore file
|
|
|
|
addValueOptionsFlags(f, valueOpts)
|
|
|
|
addValueOptionsFlags(f, valueOpts)
|
|
|
|
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|