mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
more template refactoring
This commit is contained in:
parent
8866e756fb
commit
891cf19d66
@ -279,7 +279,8 @@ class Client(object):
|
||||
dest,
|
||||
template='jinja',
|
||||
makedirs=False,
|
||||
env='base'):
|
||||
env='base',
|
||||
**kwargs):
|
||||
'''
|
||||
Cache a file then process it as a template
|
||||
'''
|
||||
@ -290,17 +291,7 @@ class Client(object):
|
||||
if template in salt.utils.templates.template_registry:
|
||||
data = template_registry[template](
|
||||
sfn,
|
||||
name=name,
|
||||
source=source,
|
||||
user=user,
|
||||
group=group,
|
||||
mode=mode,
|
||||
env=__env__,
|
||||
context=context_dict,
|
||||
salt=__salt__,
|
||||
pillar=__pillar__,
|
||||
grains=__grains__,
|
||||
opts=__opts__,
|
||||
**kwargs
|
||||
)
|
||||
else:
|
||||
log.error('Attempted to render template with unavailable engine '
|
||||
|
@ -214,13 +214,6 @@ def _error(ret, err_msg):
|
||||
return ret
|
||||
|
||||
|
||||
template_registry = {
|
||||
'jinja': salt.utils.templates.jinja,
|
||||
'mako': salt.utils.templates.mako,
|
||||
'py': salt.utils.templates.py,
|
||||
}
|
||||
|
||||
|
||||
def _check_perms(name, ret, user, group, mode):
|
||||
'''
|
||||
Check the permissions on files and chown if needed
|
||||
@ -502,11 +495,11 @@ def managed(name,
|
||||
if not os.path.exists(sfn):
|
||||
return _error(
|
||||
ret, ('File "{sfn}" could not be found').format(sfn=sfn))
|
||||
if template in template_registry:
|
||||
if template in salt.utils.templates.template_registry:
|
||||
context_dict = defaults if defaults else {}
|
||||
if context:
|
||||
context_dict.update(context)
|
||||
data = template_registry[template](
|
||||
data = salt.utils.templates.template_registry[template](
|
||||
sfn,
|
||||
name=name,
|
||||
source=source,
|
||||
|
@ -13,6 +13,7 @@ import copy
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def mako(sfn, **kwargs):
|
||||
'''
|
||||
Render a mako template, returns the location of the rendered file,
|
||||
@ -122,3 +123,10 @@ def py(sfn, **kwargs):
|
||||
trb = traceback.format_exc()
|
||||
return {'result': False,
|
||||
'data': trb}
|
||||
|
||||
template_registry = {
|
||||
'jinja': jinja,
|
||||
'mako': mako,
|
||||
'py': py,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user