Skip to content

Commit 50d0521

Browse files
committed
Adding Jinja2 templates troubleshooting
1 parent 165c7d9 commit 50d0521

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

ecs_files_composer/ecs_files_composer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def init_config(
9696
raise ImportError("Failed to import a configuration content")
9797
LOG.debug(initial_config)
9898
temp_dir = TemporaryDirectory()
99-
config_path = f"{temp_dir.name}/init_config.conf"
99+
config_path = f"{temp_dir.name}/init.conf"
100100
jobs_input_def = {
101101
"files": {config_path: initial_config},
102102
"IamOverride": iam_override,

ecs_files_composer/files_mgmt.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from tempfile import TemporaryDirectory
1313
from typing import Any
1414

15+
import jinja2.exceptions
1516
import requests
1617
from botocore.response import StreamingBody
1718
from jinja2 import Environment, FileSystemLoader
@@ -175,6 +176,8 @@ def render_jinja(self):
175176
Allows to use the temp directory as environment base, the original file as source template, and render
176177
a final template.
177178
"""
179+
from os import listdir
180+
178181
LOG.info(f"Rendering Jinja for {self.path} - {self.templates_dir.name}")
179182
jinja_env = Environment(
180183
loader=FileSystemLoader(self.templates_dir.name),
@@ -183,9 +186,14 @@ def render_jinja(self):
183186
)
184187
jinja_env.filters.update(JINJA_FILTERS)
185188
jinja_env.globals.update(JINJA_FUNCTIONS)
186-
template = jinja_env.get_template(path.basename(self.path))
187-
self.content = template.render(env=os.environ)
188-
self.write_content(is_template=False)
189+
try:
190+
template = jinja_env.get_template(path.basename(self.path))
191+
self.content = template.render(env=os.environ)
192+
self.write_content(is_template=False)
193+
except jinja2.exceptions.TemplateNotFound as error:
194+
LOG.exception(error)
195+
LOG.error(listdir(self.templates_dir.name))
196+
raise
189197

190198
def set_unix_settings(self):
191199
"""

ecs_files_composer/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: ecs-files-input.json
3-
# timestamp: 2022-07-27T09:21:37+00:00
3+
# timestamp: 2022-07-28T00:59:13+00:00
44

55
from __future__ import annotations
66

0 commit comments

Comments
 (0)