lang: Fix new `trim*` function mappings

Fixes #23413
This commit is contained in:
George Christou 2019-11-19 10:10:33 +00:00
parent 6470a56fac
commit 23fc68cc91
No known key found for this signature in database
GPG Key ID: B62A5D71FE6CAC90
3 changed files with 26 additions and 1 deletions

View File

@ -1,10 +1,11 @@
## 0.12.17 (Unreleased)
## 0.12.16 (November 18, 2019)
NEW FEATURES:
* lang/funcs: Add `trim*` functions
## 0.12.16 (November 18, 2019)
BUG FIXES:
* command/0.12upgrade: fix panic when int value is out of range ([#23394](https://github.com/hashicorp/terraform/issues/23394))

View File

@ -118,7 +118,10 @@ func (s *Scope) Functions() map[string]function.Function {
"tolist": funcs.MakeToFunc(cty.List(cty.DynamicPseudoType)),
"tomap": funcs.MakeToFunc(cty.Map(cty.DynamicPseudoType)),
"transpose": funcs.TransposeFunc,
"trim": funcs.TrimFunc,
"trimprefix": funcs.TrimPrefixFunc,
"trimspace": funcs.TrimSpaceFunc,
"trimsuffix": funcs.TrimSuffixFunc,
"upper": stdlib.UpperFunc,
"urlencode": funcs.URLEncodeFunc,
"uuid": funcs.UUIDFunc,

View File

@ -837,6 +837,20 @@ func TestFunctions(t *testing.T) {
},
},
"trim": {
{
`trim("?!hello?!", "!?")`,
cty.StringVal("hello"),
},
},
"trimprefix": {
{
`trimprefix("helloworld", "hello")`,
cty.StringVal("world"),
},
},
"trimspace": {
{
`trimspace(" hello ")`,
@ -844,6 +858,13 @@ func TestFunctions(t *testing.T) {
},
},
"trimsuffix": {
{
`trimsuffix("helloworld", "world")`,
cty.StringVal("hello"),
},
},
"upper": {
{
`upper("hello")`,