mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 02:20:53 +00:00
Configurable extensions for template parser
This commit is contained in:
@@ -81,7 +81,7 @@ func TestTemplateFiles(t *testing.T) {
|
||||
{
|
||||
name: "rejects non-.template.yaml files",
|
||||
paths: []string{"testdata/ignore.yaml"},
|
||||
wantErr: "file testdata/ignore.yaml did not have required extension .template.yaml",
|
||||
wantErr: "file testdata/ignore.yaml does not have any of permitted extensions [.template.yaml]",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@@ -114,6 +114,23 @@ func TestTemplateFiles(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTemplateParser_WithExtensions(t *testing.T) {
|
||||
p := parser.TemplateFiles("testdata").WithExtensions(".json")
|
||||
templates, err := p.Parse()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, templates, 2)
|
||||
|
||||
p = p.WithExtensions(".yaml")
|
||||
templates, err = p.Parse()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, templates, 3)
|
||||
|
||||
p = p.WithExtensions(".yaml", ".json")
|
||||
templates, err = p.Parse()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, templates, 5)
|
||||
}
|
||||
|
||||
func TestTemplateStrings(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user