MCPcopy
hub / github.com/helm/helm / newLintCmd

Function newLintCmd

pkg/cmd/lint.go:46–155  ·  view source on GitHub ↗
(out io.Writer)

Source from the content-addressed store, hash-verified

44`
45
46func newLintCmd(out io.Writer) *cobra.Command {
47 client := action.NewLint()
48 valueOpts := &values.Options{}
49 var kubeVersion string
50
51 cmd := &cobra.Command{
52 Use: "lint PATH",
53 Short: "examine a chart for possible issues",
54 Long: longLintHelp,
55 Args: require.MinimumNArgs(1),
56 RunE: func(_ *cobra.Command, args []string) error {
57 paths := args
58
59 if kubeVersion != "" {
60 parsedKubeVersion, err := common.ParseKubeVersion(kubeVersion)
61 if err != nil {
62 return fmt.Errorf("invalid kube version '%s': %s", kubeVersion, err)
63 }
64 client.KubeVersion = parsedKubeVersion
65 }
66
67 if client.WithSubcharts {
68 for _, p := range paths {
69 filepath.Walk(filepath.Join(p, "charts"), func(path string, info os.FileInfo, _ error) error {
70 if info != nil {
71 if info.Name() == "Chart.yaml" {
72 paths = append(paths, filepath.Dir(path))
73 } else if strings.HasSuffix(path, ".tgz") || strings.HasSuffix(path, ".tar.gz") {
74 paths = append(paths, path)
75 }
76 }
77 return nil
78 })
79 }
80 }
81
82 client.Namespace = settings.Namespace()
83 vals, err := valueOpts.MergeValues(getter.All(settings))
84 if err != nil {
85 return err
86 }
87
88 var message strings.Builder
89 failed := 0
90 errorsOrWarnings := 0
91
92 for _, path := range paths {
93 result := client.Run([]string{path}, vals)
94
95 // If there is no errors/warnings and quiet flag is set
96 // go to the next chart
97 hasWarningsOrErrors := action.HasWarningsOrErrors(result)
98 if hasWarningsOrErrors {
99 errorsOrWarnings++
100 }
101 if client.Quiet && !hasWarningsOrErrors {
102 continue
103 }

Callers 1

newRootCmdWithConfigFunction · 0.85

Calls 12

MergeValuesMethod · 0.95
RunMethod · 0.95
NewLintFunction · 0.92
MinimumNArgsFunction · 0.92
ParseKubeVersionFunction · 0.92
AllFunction · 0.92
HasWarningsOrErrorsFunction · 0.92
addValueOptionsFlagsFunction · 0.85
NameMethod · 0.65
DirMethod · 0.65
NamespaceMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…