-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support a directory or multiple template file arguments. #41
Comments
Globbing template files would be nice I think--no directory, as I would prefer something like this:
Additionally if the variables file is explicitly given it is used for all templates found. But if it is not given variables are looked for every template by the Yasha's automatic look up mechanism. Similarly variables given via cli call are passed to every template found, e.g.,
What do you think? |
Also if output file is explicitly given all templates are rendered (appended) into that file.
|
Sounds good to me, I'll get you a PR. Thanks! |
I was thinking about how this could be supported. Maybe |
I'm working on this. However, the whole import click
import pathlib2 as pathlib
class TemplateFile(click.File):
def glob(self, pattern, param, ctx):
files = []
for p in pathlib.Path('.').glob(pattern):
if p.is_dir():
continue # skip directories
p = super().convert(str(p), param, ctx)
files.append(p)
return files
def convert(self, value, param, ctx):
try:
return super().convert(value, param, ctx)
except click.exceptions.BadParameter:
if '*' in value:
return self.glob(value, param, ctx)
else:
raise |
I would love to add this to our terraform process since it would fill in the gaps in HCL, however passing it each file or adding a makefile to the project seems like overkill.
Yasha should support a directory or multiple files via bash globbing so that:
yasha .
Would find all j2 templates and render them. Any files found would have the rendered file in the same directory. As an example consider the following directory structure:
When yasha is run as above in the myproject directory it would result in a file sometemplate.tf at the following path
./mydir/sometemplate.tf
I'd be happy to submit a patch for this if this is something that would be accepted.
The text was updated successfully, but these errors were encountered: