Merge pull request #23414 from gechr/gc-fix-trim-func-mappings

lang: Fix new `trim*` function mappings
This commit is contained in:
Pam Selle 2019-11-19 15:01:34 -05:00 committed by GitHub
commit 285e545735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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")`,