Merge pull request #42 from atomicptr/fix/env-stdin
Fix not being able to use the env format with stdin
This commit is contained in:
commit
d3d78db8ff
|
@ -177,7 +177,7 @@ NGINX_LOGS=/var/log/nginx/
|
|||
And render with:
|
||||
|
||||
$ j2 config.j2 data.env
|
||||
$ env | j2 --format=env config.j2.
|
||||
$ env | j2 --format=env config.j2
|
||||
|
||||
This is especially useful with Docker to link containers together.
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ def render_command(cwd, environ, stdin, argv):
|
|||
}[os.path.splitext(args.data)[1]]
|
||||
|
||||
# Input: data
|
||||
if args.data == '-' and args.format == 'env':
|
||||
if args.data == '-' and args.format == 'env' and (stdin is None or stdin.isatty()):
|
||||
input_data_f = None
|
||||
else:
|
||||
input_data_f = stdin if args.data == '-' else open(args.data)
|
||||
|
|
|
@ -113,7 +113,7 @@ def _parse_env(data_string):
|
|||
And render with:
|
||||
|
||||
$ j2 config.j2 data.env
|
||||
$ env | j2 --format=env config.j2.
|
||||
$ env | j2 --format=env config.j2
|
||||
|
||||
This is especially useful with Docker to link containers together.
|
||||
"""
|
||||
|
|
|
@ -98,6 +98,8 @@ class RenderTest(unittest.TestCase):
|
|||
self._testme_std(['resources/nginx-env.j2', 'resources/data.env'])
|
||||
# Format
|
||||
self._testme_std(['--format=env', 'resources/nginx-env.j2', 'resources/data.env'])
|
||||
# Stdin
|
||||
self._testme_std(['--format=env', 'resources/nginx-env.j2'], stdin=open('resources/data.env'))
|
||||
|
||||
# Environment!
|
||||
env = dict(NGINX_HOSTNAME='localhost', NGINX_WEBROOT='/var/www/project', NGINX_LOGS='/var/log/nginx/')
|
||||
|
|
Loading…
Reference in New Issue