Skip to content

Commit

Permalink
fix(stencil): use templates/ as the base directory if present (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredallard authored Apr 5, 2022
1 parent c6cc1c4 commit 7ae545d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/codegen/stencil.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ func (s *Stencil) getTemplates(ctx context.Context, log logrus.FieldLogger) ([]*
}

log.Debugf("Discovering templates from module %q", m.Name)

// default to templates/, but if it's not present fallback to
// the root w/ a warning
if inf, err := fs.Stat("templates"); err != nil || !inf.IsDir() {
log.Warnf("Module %q has templates outside of templates/ directory, this is not recommended and is deprecated", m.Name)
} else {
var err error
fs, err = fs.Chroot("templates")
if err != nil {
return nil, errors.Wrap(err, "failed to chroot module filesystem to templates/")
}
}

err = util.Walk(fs, "", func(path string, inf os.FileInfo, err error) error {
if err != nil {
return err
Expand Down

0 comments on commit 7ae545d

Please sign in to comment.