diff --git a/CHANGELOG.md b/CHANGELOG.md index 12cb9e4e3..691315b3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/lang/functions.go b/lang/functions.go index 8c089a552..fd820df04 100644 --- a/lang/functions.go +++ b/lang/functions.go @@ -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, diff --git a/lang/functions_test.go b/lang/functions_test.go index 13c19c655..0221f2500 100644 --- a/lang/functions_test.go +++ b/lang/functions_test.go @@ -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")`,