Skip to content

Commit cfc76cb

Browse files
committed
feat: add jinja2 support for ecs.yml files
1 parent 267c7b7 commit cfc76cb

File tree

3 files changed

+99
-5
lines changed

3 files changed

+99
-5
lines changed

easyecs/helpers/settings.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
import os
44
import yaml
5-
from yaml import SafeLoader
5+
from jinja2 import Environment, FileSystemLoader
66

77
from easyecs.cloudformation.fetch import (
88
fetch_account_id,
@@ -16,9 +16,13 @@
1616

1717

1818
def read_ecs_file(file_name: str) -> EcsFileModel:
19+
env = Environment(loader=FileSystemLoader("."))
1920
with open(file_name) as f:
20-
data = yaml.load(f, Loader=SafeLoader)
21-
return EcsFileModel(**data)
21+
data = f.read()
22+
template = env.from_string(data)
23+
rendered_template = template.render(**os.environ)
24+
rendered_data = yaml.safe_load(rendered_template)
25+
return EcsFileModel(**rendered_data)
2226

2327

2428
def compute_hash_ecs_file(file_name: str):

poetry.lock

Lines changed: 90 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "easyecs"
3-
version = "0.15.0"
3+
version = "0.16.0"
44
description = ""
55
authors = ["BONVARLET Benjamin <benjaminbonvarlet96@gmail.com>"]
66
readme = "README.md"
@@ -14,6 +14,7 @@ aws-cdk-lib = "^2.89.0"
1414
pyyaml = "^6.0.1"
1515
pydantic = "^2.1.1"
1616
watchdog = "^3.0.0"
17+
jinja2 = "^3.1.6"
1718

1819
[tool.poetry.scripts]
1920
easyecs = "easyecs.cli:entrypoint"

0 commit comments

Comments
 (0)