diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index 91783d09..88a4374b 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -383,6 +383,7 @@ func (g Generator) renderTemplate(ctx context.Context, templateText string, temp funcMap := sprig.TxtFuncMap() funcMap["include"] = g.include + funcMap["includeSelf"] = g.includeSelf t, err := template.New("main").Funcs(funcMap).Option("missingkey=error").Parse(templateText) if err != nil { @@ -400,7 +401,15 @@ func (g Generator) renderTemplate(ctx context.Context, templateText string, temp } func (g Generator) include(templateName string, templateData interface{}) (string, error) { - contents, err := g.fs.ReadFile(path.Join("include", templateName+".yaml.template")) + return g.includeFromRoot("include", templateName, templateData) +} + +func (g Generator) includeSelf(templateName string, templateData interface{}) (string, error) { + return g.includeFromRoot("include-self", templateName, templateData) +} + +func (g Generator) includeFromRoot(root string, templateName string, templateData interface{}) (string, error) { + contents, err := g.fs.ReadFile(path.Join(root, templateName+".yaml.template")) if err != nil { return "", microerror.Mask(err) }