Skip to content

Commit 4e983a2

Browse files
esbenEmantor
authored andcommitted
remote/config: allow use of environment variables in exporter config
This extends the jinja2 templating support in exporter configuration file with support for using OS environment variables. Signed-off-by: Esben Haabendal <[email protected]> [[email protected]: rebased] Signed-off-by: Rouven Czerwinski <[email protected]>
1 parent 8503839 commit 4e983a2

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGES.rst

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ New Features in 0.3.0
6565
Labgrid.
6666
- ``labgrid-client write-image`` gained a new argument ``--mode`` to specify
6767
which tool should be used to write the image (either ``dd`` or ``bmaptool``)
68+
- Exporter configuration file ``exporter.yaml`` now allows use of environment
69+
variables.
6870

6971
Breaking changes in 0.3.0
7072
~~~~~~~~~~~~~~~~~~~~~~~~~

doc/configuration.rst

+4
Original file line numberDiff line numberDiff line change
@@ -2211,3 +2211,7 @@ Use ``#`` for line statements (like the for loops in the example) and ``##``
22112211
for line comments.
22122212
Statements like ``{{ 4000 + idx }}`` are expanded based on variables in the
22132213
Jinja2 template.
2214+
2215+
The template processing also supports use of OS environment variables, using
2216+
something like `{{ env['FOOBAR'] }}` to insert the content of environment
2217+
variable `FOOBAR`.

labgrid/remote/config.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import attr
44
import jinja2
5+
import os
56

67
from ..util.yaml import load
78
from ..exceptions import NoConfigFoundError
@@ -23,7 +24,7 @@ def __attrs_post_init__(self):
2324
raise NoConfigFoundError(
2425
"{} could not be found".format(self.filename)
2526
)
26-
rendered = template.render()
27+
rendered = template.render(env=os.environ)
2728
pprint(('rendered', rendered))
2829
self.data = load(rendered)
2930
pprint(('loaded', self.data))

0 commit comments

Comments
 (0)