From 707f39b44038e6a5f41caa75bf2e4b82a1658b92 Mon Sep 17 00:00:00 2001 From: Dirk Leser <44613881+dleser@users.noreply.github.com> Date: Fri, 6 May 2022 09:28:42 +0200 Subject: [PATCH 1/3] Added example with function argument expansion Even if the expansion with three dots is explicity mentioned in https://www.terraform.io/language/expressions/function-calls#expanding-function-arguments the additional example would have helped me a lot as it is a common use case to "flatten" a list of maps. --- website/docs/language/functions/merge.mdx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/docs/language/functions/merge.mdx b/website/docs/language/functions/merge.mdx index 22e97d35e0..3cd78a7dfa 100644 --- a/website/docs/language/functions/merge.mdx +++ b/website/docs/language/functions/merge.mdx @@ -27,6 +27,15 @@ type structure of the attributes after the merging rules have been applied. } ``` +``` +> merge([{a="b", c="d"}, {}, {e="f", c="z"}]...) +{ + "a" = "b" + "c" = "z" + "e" = "f" +} +``` + ``` > merge({a="b"}, {a=[1,2], c="z"}, {d=3}) { From 37d18f422915423d797fd5bc308ec3ec16249251 Mon Sep 17 00:00:00 2001 From: Dirk Leser <44613881+dleser@users.noreply.github.com> Date: Fri, 17 Jun 2022 14:32:02 +0200 Subject: [PATCH 2/3] functions/merge: Added expanation for example Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com> --- website/docs/language/functions/merge.mdx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/website/docs/language/functions/merge.mdx b/website/docs/language/functions/merge.mdx index 3cd78a7dfa..8fc691a4c8 100644 --- a/website/docs/language/functions/merge.mdx +++ b/website/docs/language/functions/merge.mdx @@ -27,14 +27,7 @@ type structure of the attributes after the merging rules have been applied. } ``` -``` -> merge([{a="b", c="d"}, {}, {e="f", c="z"}]...) -{ - "a" = "b" - "c" = "z" - "e" = "f" -} -``` +The following example uses the expansion symbol (...) to transform the value into separate arguments. Refer to [Expanding Function Argument](/language/expressions/function-calls#expanding-function-arguments) for details. ``` > merge({a="b"}, {a=[1,2], c="z"}, {d=3}) From ab93ef09eccfc917818aee78112614272e32f06f Mon Sep 17 00:00:00 2001 From: Dirk Leser <44613881+dleser@users.noreply.github.com> Date: Fri, 17 Jun 2022 14:42:52 +0200 Subject: [PATCH 3/3] Readded the new example below the description --- website/docs/language/functions/merge.mdx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/website/docs/language/functions/merge.mdx b/website/docs/language/functions/merge.mdx index 8fc691a4c8..dfc70aaa28 100644 --- a/website/docs/language/functions/merge.mdx +++ b/website/docs/language/functions/merge.mdx @@ -27,8 +27,6 @@ type structure of the attributes after the merging rules have been applied. } ``` -The following example uses the expansion symbol (...) to transform the value into separate arguments. Refer to [Expanding Function Argument](/language/expressions/function-calls#expanding-function-arguments) for details. - ``` > merge({a="b"}, {a=[1,2], c="z"}, {d=3}) { @@ -40,3 +38,14 @@ The following example uses the expansion symbol (...) to transform the value int "d" = 3 } ``` + +The following example uses the expansion symbol (...) to transform the value into separate arguments. Refer to [Expanding Function Argument](/language/expressions/function-calls#expanding-function-arguments) for details. + +``` +> merge([{a="b", c="d"}, {}, {e="f", c="z"}]...) +{ + "a" = "b" + "c" = "z" + "e" = "f" +} +```