diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 9a2e8d31c..b53309b20 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -19,6 +19,8 @@ package main import ( "fmt" "io" + "os" + "path/filepath" "strings" "github.com/pkg/errors" @@ -51,6 +53,21 @@ func newLintCmd(out io.Writer) *cobra.Command { if len(args) > 0 { paths = args } + if client.WithSubcharts { + for _, p := range paths { + filepath.Walk(filepath.Join(p, "/charts"), func(path string, info os.FileInfo, err error) error { + if info != nil { + if info.Name() == "Chart.yaml" { + paths = append(paths, filepath.Dir(path)) + } else if strings.HasSuffix(path, ".tgz") || strings.HasSuffix(path, ".tar.gz") { + paths = append(paths, path) + } + } + return nil + }) + } + } + client.Namespace = settings.Namespace() vals, err := valueOpts.MergeValues(getter.All(settings)) if err != nil { @@ -102,6 +119,7 @@ func newLintCmd(out io.Writer) *cobra.Command { f := cmd.Flags() f.BoolVar(&client.Strict, "strict", false, "fail on lint warnings") + f.BoolVar(&client.WithSubcharts, "with-subcharts", false, "lint dependent charts") addValueOptionsFlags(f, valueOpts) return cmd diff --git a/pkg/action/lint.go b/pkg/action/lint.go index c216c5832..ddb0101c7 100644 --- a/pkg/action/lint.go +++ b/pkg/action/lint.go @@ -33,8 +33,9 @@ import ( // // It provides the implementation of 'helm lint'. type Lint struct { - Strict bool - Namespace string + Strict bool + Namespace string + WithSubcharts bool } type LintResult struct {