From 9a2837b7a9ba30b74bb43469a3a7757434e9fe82 Mon Sep 17 00:00:00 2001 From: Dennis Twardowsky Date: Tue, 6 Jul 2021 23:29:20 +0200 Subject: [PATCH] --env assigns all variables to content, instead of dotenv file --- renderTemplate.py | 11 ++++------- template/testenv.tpl | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 template/testenv.tpl diff --git a/renderTemplate.py b/renderTemplate.py index 41b6237..8f93218 100755 --- a/renderTemplate.py +++ b/renderTemplate.py @@ -5,7 +5,6 @@ import os import socket import sys -import dotenv import toml import yaml from jinja2 import Environment, TemplateError @@ -22,9 +21,8 @@ infilegroup.add_argument('--toml', dest='toml_file', type=str, required=False, help='TOML file path') infilegroup.add_argument('--ini', dest='ini_file', type=str, required=False, help='INI fil path') - -argsparser.add_argument('--env', dest='env_file', type=bool, required=False, action='store_true', - help='Load .env file from current directory') +infilegroup.add_argument('--env', dest='env_file', action='store_true', + help='Load environment variables') argsparser.add_argument('--output', default='/dev/stdout', help='Output File') @@ -160,9 +158,8 @@ if __name__ == '__main__': # If template was found if tpl: if args.env_file: - dotenv.load_dotenv(dotenv.find_dotenv(raise_error_if_not_found=False)) - # Load content from file, if present - if args.yaml_file: + content = os.environ + elif args.yaml_file: content = load_yaml_file(args.yaml_file) elif args.json_file: content = load_json_file(args.json_file) diff --git a/template/testenv.tpl b/template/testenv.tpl new file mode 100644 index 0000000..2753822 --- /dev/null +++ b/template/testenv.tpl @@ -0,0 +1,3 @@ +{ + "Type": "{{ TESTVAR }}", +}