diff --git a/internal/chart/v3/lint/rules/template.go b/internal/chart/v3/lint/rules/template.go index d4c62839f..4b2bce927 100644 --- a/internal/chart/v3/lint/rules/template.go +++ b/internal/chart/v3/lint/rules/template.go @@ -220,6 +220,13 @@ func validateTemplatesDir(templatesPath string) error { } func validateAllowedExtension(fileName string) error { + baseName := filepath.Base(fileName) + + if strings.HasPrefix(baseName, "_") { + fmt.Println("skipping _ files") + return nil + } + ext := filepath.Ext(fileName) validExtensions := []string{".yaml", ".yml", ".tpl", ".txt"} diff --git a/internal/chart/v3/lint/rules/template_test.go b/internal/chart/v3/lint/rules/template_test.go index 40bcfa26b..598ccf1e6 100644 --- a/internal/chart/v3/lint/rules/template_test.go +++ b/internal/chart/v3/lint/rules/template_test.go @@ -32,14 +32,14 @@ import ( const templateTestBasedir = "./testdata/albatross" func TestValidateAllowedExtension(t *testing.T) { - var failTest = []string{"/foo", "/test.toml"} + var failTest = []string{"/foo", "/test.toml", "regular.json"} for _, test := range failTest { err := validateAllowedExtension(test) if err == nil || !strings.Contains(err.Error(), "Valid extensions are .yaml, .yml, .tpl, or .txt") { t.Errorf("validateAllowedExtension('%s') to return \"Valid extensions are .yaml, .yml, .tpl, or .txt\", got no error", test) } } - var successTest = []string{"/foo.yaml", "foo.yaml", "foo.tpl", "/foo/bar/baz.yaml", "NOTES.txt"} + var successTest = []string{"/foo.yaml", "foo.yaml", "foo.tpl", "/foo/bar/baz.yaml", "NOTES.txt", "_envoy.json"} for _, test := range successTest { err := validateAllowedExtension(test) if err != nil { diff --git a/pkg/chart/v2/lint/rules/template.go b/pkg/chart/v2/lint/rules/template.go index 5c84d0f68..3006d8af8 100644 --- a/pkg/chart/v2/lint/rules/template.go +++ b/pkg/chart/v2/lint/rules/template.go @@ -220,6 +220,12 @@ func validateTemplatesDir(templatesPath string) error { } func validateAllowedExtension(fileName string) error { + baseName := filepath.Base(fileName) + + if strings.HasPrefix(baseName, "_") { + return nil + } + ext := filepath.Ext(fileName) validExtensions := []string{".yaml", ".yml", ".tpl", ".txt"} diff --git a/pkg/chart/v2/lint/rules/template_test.go b/pkg/chart/v2/lint/rules/template_test.go index 3e8e0b371..9ad66800a 100644 --- a/pkg/chart/v2/lint/rules/template_test.go +++ b/pkg/chart/v2/lint/rules/template_test.go @@ -32,14 +32,14 @@ import ( const templateTestBasedir = "./testdata/albatross" func TestValidateAllowedExtension(t *testing.T) { - var failTest = []string{"/foo", "/test.toml"} + var failTest = []string{"/foo", "/test.toml", "regular.json"} for _, test := range failTest { err := validateAllowedExtension(test) if err == nil || !strings.Contains(err.Error(), "Valid extensions are .yaml, .yml, .tpl, or .txt") { t.Errorf("validateAllowedExtension('%s') to return \"Valid extensions are .yaml, .yml, .tpl, or .txt\", got no error", test) } } - var successTest = []string{"/foo.yaml", "foo.yaml", "foo.tpl", "/foo/bar/baz.yaml", "NOTES.txt"} + var successTest = []string{"/foo.yaml", "foo.yaml", "foo.tpl", "/foo/bar/baz.yaml", "NOTES.txt", "_regular.json"} for _, test := range successTest { err := validateAllowedExtension(test) if err != nil {