Make template params resolution standalone
This makes the two functions for resolving template data (Fn::FindInMap, Ref, etc.) available outside of a Stack object. Other programs can then import these functions and see how the template parameters get resolved. Change-Id: I92de937a3fb25f907404335cb71554036a807c50 Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
This commit is contained in:
parent
70bdc38a44
commit
e611c7a517
@ -614,20 +614,38 @@ class Stack(object):
|
||||
# restart the whole stack
|
||||
|
||||
def resolve_static_data(self, snippet):
|
||||
return transform(snippet,
|
||||
[functools.partial(self.t.resolve_param_refs,
|
||||
parameters=self.parameters),
|
||||
self.t.resolve_availability_zones,
|
||||
self.t.resolve_find_in_map])
|
||||
return resolve_static_data(self.t, self.parameters, snippet)
|
||||
|
||||
def resolve_runtime_data(self, snippet):
|
||||
return transform(snippet,
|
||||
[functools.partial(self.t.resolve_resource_refs,
|
||||
resources=self.resources),
|
||||
functools.partial(self.t.resolve_attributes,
|
||||
resources=self.resources),
|
||||
self.t.resolve_joins,
|
||||
self.t.resolve_base64])
|
||||
return resolve_runtime_data(self.t, self.resources, snippet)
|
||||
|
||||
|
||||
def resolve_static_data(template, parameters, snippet):
|
||||
'''
|
||||
Resolve static parameters, map lookups, etc. in a template.
|
||||
|
||||
Example:
|
||||
|
||||
>>> template = Template(json.load(template_path))
|
||||
>>> parameters = Parameters('stack', template, {'KeyName': 'my_key'})
|
||||
>>> resolve_static_data(template, parameters, {'Ref': 'KeyName'})
|
||||
'my_key'
|
||||
'''
|
||||
return transform(snippet,
|
||||
[functools.partial(template.resolve_param_refs,
|
||||
parameters=parameters),
|
||||
template.resolve_availability_zones,
|
||||
template.resolve_find_in_map])
|
||||
|
||||
|
||||
def resolve_runtime_data(template, resources, snippet):
|
||||
return transform(snippet,
|
||||
[functools.partial(template.resolve_resource_refs,
|
||||
resources=resources),
|
||||
functools.partial(template.resolve_attributes,
|
||||
resources=resources),
|
||||
template.resolve_joins,
|
||||
template.resolve_base64])
|
||||
|
||||
|
||||
def transform(data, transformations):
|
||||
|
Loading…
Reference in New Issue
Block a user