Skip to content

Commit

Permalink
vyos.template: T3664: use a module-level global variable for the defa…
Browse files Browse the repository at this point in the history
…ult template directory

as a more convenient and secure alternative to environment variable

(cherry picked from commit 9aa8c3c)

# Conflicts:
#	python/vyos/template.py
  • Loading branch information
dmbaturin authored and mergify[bot] committed May 6, 2024
1 parent 199ee2d commit a411be3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/vyos/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
from vyos.utils.permission import chmod
from vyos.utils.permission import chown

# We use a mutable global variable for the default template directory
# to make it possible to call scripts from this repository
# outside of live VyOS systems.
# If something (like the image build scripts)
# want to call a script, they can modify the default location
# to the repository path.
DEFAULT_TEMPLATE_DIR = directories["templates"]

# Holds template filters registered via register_filter()
_FILTERS = {}
_TESTS = {}
Expand All @@ -33,7 +41,11 @@
@functools.lru_cache(maxsize=2)
def _get_environment(location=None):
if location is None:
<<<<<<< HEAD
loc_loader=FileSystemLoader(directories["templates"])
=======
loc_loader=FileSystemLoader(DEFAULT_TEMPLATE_DIR)
>>>>>>> 9aa8c3cd9 (vyos.template: T3664: use a module-level global variable for the default template directory)
else:
loc_loader=FileSystemLoader(location)
env = Environment(
Expand Down

0 comments on commit a411be3

Please sign in to comment.