mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
parent
f056efc1c9
commit
4d29438233
@ -44,7 +44,7 @@ class SaltMakoTemplateLookup(TemplateCollection):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, opts, saltenv='base', env=None):
|
||||
def __init__(self, opts, saltenv='base', env=None, pillar_rend=False):
|
||||
if env is not None:
|
||||
salt.utils.warn_until(
|
||||
'Boron',
|
||||
@ -56,10 +56,20 @@ class SaltMakoTemplateLookup(TemplateCollection):
|
||||
saltenv = env
|
||||
self.opts = opts
|
||||
self.saltenv = saltenv
|
||||
self.file_client = salt.fileclient.get_file_client(self.opts)
|
||||
self._file_client = None
|
||||
self.pillar_rend = pillar_rend
|
||||
self.lookup = TemplateLookup(directories='/')
|
||||
self.cache = {}
|
||||
|
||||
def file_client(self):
|
||||
'''
|
||||
Setup and return file_client
|
||||
'''
|
||||
if not self._file_client:
|
||||
self._file_client = salt.fileclient.get_file_client(
|
||||
self.opts, self.pillar_rend)
|
||||
return self._file_client
|
||||
|
||||
def adjust_uri(self, uri, filename):
|
||||
scheme = urlparse(uri).scheme
|
||||
if scheme in ('salt', 'file'):
|
||||
@ -93,7 +103,7 @@ class SaltMakoTemplateLookup(TemplateCollection):
|
||||
|
||||
def cache_file(self, fpath):
|
||||
if fpath not in self.cache:
|
||||
self.cache[fpath] = self.file_client.get_file(fpath,
|
||||
self.cache[fpath] = self.file_client().get_file(fpath,
|
||||
'',
|
||||
True,
|
||||
self.saltenv)
|
||||
|
@ -435,7 +435,10 @@ def render_mako_tmpl(tmplstr, context, tmplpath=None):
|
||||
from mako.lookup import TemplateLookup
|
||||
lookup = TemplateLookup(directories=[os.path.dirname(tmplpath)])
|
||||
else:
|
||||
lookup = SaltMakoTemplateLookup(context['opts'], saltenv)
|
||||
lookup = SaltMakoTemplateLookup(
|
||||
context['opts'],
|
||||
saltenv,
|
||||
pillar_rend=context.get('_pillar_rend', False))
|
||||
try:
|
||||
return Template(
|
||||
tmplstr,
|
||||
|
Loading…
Reference in New Issue
Block a user