diff --git a/CHANGES.rst b/CHANGES.rst index e9be5b245..b527e3497 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -65,6 +65,8 @@ New Features in 0.3.0 Labgrid. - ``labgrid-client write-image`` gained a new argument ``--mode`` to specify which tool should be used to write the image (either ``dd`` or ``bmaptool``) +- Exporter configuration file ``exporter.yaml`` now allows use of environment + variables. Breaking changes in 0.3.0 ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/configuration.rst b/doc/configuration.rst index 08232fa0b..f596c76fa 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -2211,3 +2211,7 @@ Use ``#`` for line statements (like the for loops in the example) and ``##`` for line comments. Statements like ``{{ 4000 + idx }}`` are expanded based on variables in the Jinja2 template. + +The template processing also supports use of OS environment variables, using +something like `{{ env['FOOBAR'] }}` to insert the content of environment +variable `FOOBAR`. diff --git a/labgrid/remote/config.py b/labgrid/remote/config.py index 6370162b4..f7bf6faf1 100644 --- a/labgrid/remote/config.py +++ b/labgrid/remote/config.py @@ -2,6 +2,7 @@ import attr import jinja2 +import os from ..util.yaml import load from ..exceptions import NoConfigFoundError @@ -23,7 +24,7 @@ def __attrs_post_init__(self): raise NoConfigFoundError( "{} could not be found".format(self.filename) ) - rendered = template.render() + rendered = template.render(env=os.environ) pprint(('rendered', rendered)) self.data = load(rendered) pprint(('loaded', self.data))