Skip to content

Commit

Permalink
Option to indicate whether the config render should use Jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnPreston committed Sep 28, 2021
1 parent 6f8e08f commit 5ea1e54
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
37 changes: 31 additions & 6 deletions ecs_files_composer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def main():
required=False,
default=False,
)
parser.add_argument(
"--with-jinja2",
help="Whether the source config should be rendered with Jinja2",
action="store_true",
required=False,
default=False,
)
parser.add_argument("_", nargs="*")
args = parser.parse_args()
print("Arguments: " + str(args._))
Expand All @@ -68,21 +75,39 @@ def main():
) and environ.get("ECS_CONFIG_CONTENT", None):
LOG.info("Using default env variable ECS_CONFIG_CONTENT")
config = init_config(
env_var="ECS_CONFIG_CONTENT", decode_base64=args.decode_base64
env_var="ECS_CONFIG_CONTENT",
decode_base64=bool(environ.get("DECODE_BASE64", False)),
with_jinja=bool(environ.get("WITH_JINJA", False)),
)
elif args.env_var:
config = init_config(env_var=args.env_var, decode_base64=args.decode_base64)
config = init_config(
env_var=args.env_var,
decode_base64=args.decode_base64,
with_jinja=args.with_jinja,
)
elif args.file_path:
config = init_config(file_path=args.file_path, decode_base64=args.decode_base64)
config = init_config(
file_path=args.file_path,
decode_base64=args.decode_base64,
with_jinja=args.with_jinja,
)
elif args.ssm_config:
config = init_config(
ssm_parameter=args.ssm_config, decode_base64=args.decode_base64
ssm_parameter=args.ssm_config,
decode_base64=args.decode_base64,
with_jinja=args.with_jinja,
)
elif args.s3_config:
config = init_config(s3_config=args.s3_config, decode_base64=args.decode_base64)
config = init_config(
s3_config=args.s3_config,
decode_base64=args.decode_base64,
with_jinja=args.with_jinja,
)
elif args.secret_config:
config = init_config(
secret_config=args.secret_config, decode_base64=args.decode_base64
secret_config=args.secret_config,
decode_base64=args.decode_base64,
with_jinja=args.with_jinja,
)
else:
raise parser.error(
Expand Down
4 changes: 3 additions & 1 deletion ecs_files_composer/ecs_files_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def init_config(
role_arn=None,
external_id=None,
decode_base64=False,
with_jinja=False,
):
"""
Function to initialize the configuration
Expand Down Expand Up @@ -93,7 +94,8 @@ def init_config(
}
if decode_base64:
initial_config["encoding"] = "base64"
# initial_config["context"] = "jinja2"
if with_jinja:
initial_config["context"] = "jinja2"
start_jobs(jobs_input_def)
with open(config_path, "r") as config_fd:
try:
Expand Down

0 comments on commit 5ea1e54

Please sign in to comment.