Merge "HOT intrinisic function list_join like Fn::Join"

This commit is contained in:
Jenkins 2014-07-07 03:41:56 +00:00 committed by Gerrit Code Review
commit af3c236167
3 changed files with 38 additions and 3 deletions

View File

@ -726,6 +726,26 @@ The *resource ID* of the referenced resources as used in the current template is
given as single parameter to the get_resource function.
list_join
--------
The *list_join* function joins a list of strings with the given delimiter.
The syntax of the list_join function is as follows:
::
list_join:
- <delimiter>
- <list to join>
A sample use of this function with a simple list is shown below.
::
list_join: [', ', ['one', 'two', 'and three']]
This would resolve to "one, two, and three".
resource_facade
---------------
The *resource_facade* function allows a provider template to retrieve data

View File

@ -202,6 +202,20 @@ class GetFile(function.Function):
return f
class Join(cfn_funcs.Join):
'''
A function for joining strings.
Takes the form::
{ "list_join" : [ "<delim>", [ "<string_1>", "<string_2>", ... ] }
And resolves to::
"<string_1><delim><string_2><delim>..."
'''
class ResourceFacade(cfn_funcs.ResourceFacade):
'''
A function for obtaining data from the facade resource from within the
@ -235,6 +249,7 @@ def function_mapping(version_key, version):
'get_attr': GetAtt,
'Fn::Select': cfn_funcs.Select,
'Fn::Join': cfn_funcs.Join,
'list_join': Join,
'Fn::Split': cfn_funcs.Split,
'str_replace': Replace,
'Fn::Replace': cfn_funcs.Replace,

View File

@ -17,10 +17,10 @@ import six
from heat.common import exception
from heat.common import identifier
from heat.common import template_format
from heat.engine.cfn import functions as cfn_funcs
from heat.engine import constraints
from heat.engine import environment
from heat.engine import function
from heat.engine.hot import functions as hot_functions
from heat.engine.hot import parameters as hot_param
from heat.engine.hot import template as hot_template
from heat.engine import parameters
@ -585,8 +585,8 @@ class HOTemplateTest(HeatTestCase):
parent_resource.stack = parser.Stack(utils.dummy_context(),
'toplevel_stack',
parser.Template(hot_tpl_empty))
del_policy = cfn_funcs.Join(parent_resource.stack,
'Fn::Join', ['eta', ['R', 'in']])
del_policy = hot_functions.Join(parent_resource.stack,
'list_join', ['eta', ['R', 'in']])
parent_resource.t = rsrc_defn.ResourceDefinition(
'parent', 'SomeType',
deletion_policy=del_policy)