From 8c85371a35d9c6141a5c5e9453f5b2d6680d07b3 Mon Sep 17 00:00:00 2001 From: Brian Dols Date: Thu, 25 Nov 2021 09:40:56 -0600 Subject: [PATCH] warn on templates in libraries that will be skipped --- pkg/lint/rules/template.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index b4bfe33e2..bd9714067 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -99,6 +99,9 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace for _, template := range chart.Templates { fileName, data := template.Name, template.Data fpath = fileName + if chart.Metadata.Type == "library" { + linter.RunLinterRule(support.WarningSev, fpath, validateLibraryTemplate(fileName)) + } linter.RunLinterRule(support.ErrorSev, fpath, validateAllowedExtension(fileName)) // These are v3 specific checks to make sure and warn people if their @@ -179,6 +182,13 @@ func validateTopIndentLevel(content string) error { return scanner.Err() } +func validateLibraryTemplate(fileName string) error { + if fileName[0] != '_' { + return fmt.Errorf("template file name %s does not start with '_' character", fileName) + } + return nil +} + // Validation functions func validateTemplatesDir(templatesPath string) error { if fi, err := os.Stat(templatesPath); err != nil {