From 5217482c8eab1b44cc07dfcfd669c6ee47f3b9bc Mon Sep 17 00:00:00 2001 From: wujunwei Date: Thu, 29 Sep 2022 18:06:54 +0800 Subject: [PATCH] bugfix:(#11391) helm lint infinite loop when malformed template object Signed-off-by: wujunwei (cherry picked from commit 316d3fb56aff92afcf167653399ca7ea57481ed2) --- pkg/lint/rules/template.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 61425f92e..bbe82426c 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -141,10 +141,11 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace break } - // If YAML linting fails, we sill progress. So we don't capture the returned state - // on this linter run. - linter.RunLinterRule(support.ErrorSev, fpath, validateYamlContent(err)) - + // If YAML linting fails, it will always be fails next block. so we should return here. + // fix https://github.com/helm/helm/issues/11391 + if !linter.RunLinterRule(support.ErrorSev, fpath, validateYamlContent(err)) { + return + } if yamlStruct != nil { // NOTE: set to warnings to allow users to support out-of-date kubernetes // Refs https://github.com/helm/helm/issues/8596