From e2a457a8965b688222097e934913079966f28ff4 Mon Sep 17 00:00:00 2001 From: Danilo Patrucco Date: Fri, 26 Jul 2024 13:32:08 -0400 Subject: [PATCH] add variable .helmlintignore file if none is spefied Signed-off-by: Danilo Patrucco --- cmd/helm/lint.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 999955594..fb3a47b16 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -43,6 +43,8 @@ it will emit [ERROR] messages. If it encounters issues that break with conventio or recommendation, it will emit [WARNING] messages. ` +var useTempFile = false + func newLintCmd(out io.Writer) *cobra.Command { client := action.NewLint() client.Debug = settings.Debug @@ -90,16 +92,24 @@ func newLintCmd(out io.Writer) *cobra.Command { } var ignorePatterns map[string][]string - if lintIgnoreFile != "" { - debug("\nUsing ignore file: %s\n", lintIgnoreFile) - ignorePatterns, err = rules.ParseIgnoreFile(lintIgnoreFile) - } - var message strings.Builder + failed := 0 errorsOrWarnings := 0 for _, path := range paths { + useTempFile = false + if lintIgnoreFile != "" { + debug("\nUsing ignore file: %s\n", lintIgnoreFile) + } else { + lintIgnoreFile = filepath.Join(path, ".helmlintignore") + debug("\nNo HelmLintIgnore file specified, will try and use the following: %s\n", lintIgnoreFile) + useTempFile = true // Mark that a temporary file was used + } + ignorePatterns, err = rules.ParseIgnoreFile(lintIgnoreFile) + if useTempFile { + lintIgnoreFile = "" + } result := client.Run([]string{path}, vals) result.Messages = rules.FilterIgnoredMessages(result.Messages, ignorePatterns) result.Errors = rules.FilterIgnoredErrors(result.Errors, ignorePatterns)