feat(cmd/lint): added a flag for linting subcharts

Signed-off-by: Nick Lee <nmkyu.lee@gmail.com>
pull/7288/head
Nick Lee 5 years ago
parent bc45d65312
commit cf4bee7ac8

@ -19,6 +19,8 @@ package main
import ( import (
"fmt" "fmt"
"io" "io"
"os"
"path/filepath"
"strings" "strings"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -51,6 +53,21 @@ func newLintCmd(out io.Writer) *cobra.Command {
if len(args) > 0 { if len(args) > 0 {
paths = args 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() client.Namespace = settings.Namespace()
vals, err := valueOpts.MergeValues(getter.All(settings)) vals, err := valueOpts.MergeValues(getter.All(settings))
if err != nil { if err != nil {
@ -102,6 +119,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")
addValueOptionsFlags(f, valueOpts) addValueOptionsFlags(f, valueOpts)
return cmd return cmd

@ -33,8 +33,9 @@ import (
// //
// It provides the implementation of 'helm lint'. // It provides the implementation of 'helm lint'.
type Lint struct { type Lint struct {
Strict bool Strict bool
Namespace string Namespace string
WithSubcharts bool
} }
type LintResult struct { type LintResult struct {

Loading…
Cancel
Save