diff --git a/doc/source/template_guide/hot_spec.rst b/doc/source/template_guide/hot_spec.rst index 15a6249eaf..a5ce5acbc6 100644 --- a/doc/source/template_guide/hot_spec.rst +++ b/doc/source/template_guide/hot_spec.rst @@ -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: + - + - + +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 diff --git a/heat/engine/hot/functions.py b/heat/engine/hot/functions.py index abd7b42aad..1a26f0ae79 100644 --- a/heat/engine/hot/functions.py +++ b/heat/engine/hot/functions.py @@ -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" : [ "", [ "", "", ... ] } + + And resolves to:: + + "..." + ''' + + 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, diff --git a/heat/tests/test_hot.py b/heat/tests/test_hot.py index 88c41afae3..6e572ed341 100644 --- a/heat/tests/test_hot.py +++ b/heat/tests/test_hot.py @@ -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)